Beispiel #1
0
 /**
  * Sends email.
  * @param  Message
  * @return void
  */
 public function send(Message $mail)
 {
     $tmp = clone $mail;
     $tmp->setHeader('Subject', NULL);
     $tmp->setHeader('To', NULL);
     $parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
     Nette\Diagnostics\Debugger::tryError();
     $res = mail(str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]), (string) $this->commandArgs);
     if (Nette\Diagnostics\Debugger::catchError($e)) {
         throw new Nette\InvalidStateException('mail(): ' . $e->getMessage(), 0, $e);
     } elseif (!$res) {
         throw new Nette\InvalidStateException('Unable to send email.');
     }
 }
 /**
  * Sends email.
  * @return void
  */
 public function send(Message $mail)
 {
     $tmp = clone $mail;
     $tmp->setHeader('Subject', NULL);
     $tmp->setHeader('To', NULL);
     $parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
     $args = array(str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]));
     if ($this->commandArgs) {
         $args[] = (string) $this->commandArgs;
     }
     if (call_user_func_array('mail', $args) === FALSE) {
         $error = error_get_last();
         throw new Nette\InvalidStateException("Unable to send email: {$error['message']}.");
     }
 }
Beispiel #3
0
 /**
  * Sends email.
  * @return void
  */
 public function send(Message $mail)
 {
     $tmp = clone $mail;
     $tmp->setHeader('Subject', NULL);
     $tmp->setHeader('To', NULL);
     $parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
     $args = array(str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]));
     if ($this->commandArgs) {
         $args[] = (string) $this->commandArgs;
     }
     $res = Nette\Utils\Callback::invokeSafe('mail', $args, function ($message) use(&$info) {
         $info = ": {$message}";
     });
     if ($res === FALSE) {
         throw new Nette\InvalidStateException("Unable to send email{$info}.");
     }
 }
 /**
  * Sends email.
  * @return void
  */
 public function send(Message $mail)
 {
     $tmp = clone $mail;
     $tmp->setHeader('Subject', NULL);
     $tmp->setHeader('To', NULL);
     $parts = explode(Message::EOL . Message::EOL, $tmp->generateMessage(), 2);
     $args = array(str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('To')), str_replace(Message::EOL, PHP_EOL, $mail->getEncodedHeader('Subject')), str_replace(Message::EOL, PHP_EOL, $parts[1]), str_replace(Message::EOL, PHP_EOL, $parts[0]));
     if ($this->commandArgs) {
         $args[] = (string) $this->commandArgs;
     }
     set_error_handler(function ($severity, $message) use(&$info) {
         $info = ": {$message}";
     });
     $res = call_user_func_array('mail', $args);
     restore_error_handler();
     if ($res === FALSE) {
         throw new Nette\InvalidStateException("Unable to send email{$info}.");
     }
 }