Nette\Mail\SmtpMailer::send PHP Метод

send() публичный Метод

Sends email.
public send ( Nette\Mail\Message $mail ) : void
$mail Nette\Mail\Message
Результат void
    public function send(Message $mail)
    {
        $mail = clone $mail;
        try {
            if (!$this->connection) {
                $this->connect();
            }
            if (($from = $mail->getHeader('Return-Path')) || ($from = key($mail->getHeader('From')))) {
                $this->write("MAIL FROM:<{$from}>", 250);
            }
            foreach (array_merge((array) $mail->getHeader('To'), (array) $mail->getHeader('Cc'), (array) $mail->getHeader('Bcc')) as $email => $name) {
                $this->write("RCPT TO:<{$email}>", [250, 251]);
            }
            $mail->setHeader('Bcc', NULL);
            $data = $mail->generateMessage();
            $this->write('DATA', 354);
            $data = preg_replace('#^\\.#m', '..', $data);
            $this->write($data);
            $this->write('.', 250);
            if (!$this->persistent) {
                $this->write('QUIT', 221);
                $this->disconnect();
            }
        } catch (SmtpException $e) {
            if ($this->connection) {
                $this->disconnect();
            }
            throw $e;
        }
    }

Usage Example

Пример #1
0
 /**
  * Odešle vytvořenou zprávu přes SMTP.
  * @return bool
  * @throws \Nette\Mail\SmtpException V případě chyby. Pokud je prostředí produkční, je chyba zalogována do mailException.
  */
 public function send()
 {
     try {
         $this->smtpMailer->send($this->message);
         return true;
     } catch (\Nette\Mail\SmtpException $e) {
         if (\Tracy\Debugger::$productionMode) {
             \Tracy\Debugger::log($e->getMessage(), "mailException");
             return false;
         } else {
             throw $e;
         }
     }
 }
All Usage Examples Of Nette\Mail\SmtpMailer::send