public function run() { $transport = new SmtpTransport(new SmtpOptions(array('name' => $this->host, 'host' => $this->host, 'port' => $this->port, 'connection_config' => array('username' => $this->sender->getUsername(), 'password' => $this->sender->getPassword())))); if ($this->auth !== null) { $transport->getOptions()->setConnectionClass($this->auth); } $message = new Message(); $message->addFrom($this->sender->getUsername())->setSubject($this->subject); if ($this->bcc) { $message->addBcc($this->recipients); } else { $message->addTo($this->recipients); } $body = new MimeMessage(); if ($this->htmlBody == null) { $text = new MimePart($this->textBody); $text->type = "text/plain"; $body->setParts(array($text)); } else { $html = new MimePart($this->htmlBody); $html->type = "text/html"; $body->setParts(array($html)); } $message->setBody($body); $transport->send($message); }
/** * @return $this */ public function prepare() { $html = new MimePart($this->renderView($this->page, $this->data)); $html->type = "text/html"; $body = new MimeMessage(); $body->setParts(array($html)); $this->body = $body; $config = $this->transport->getOptions()->toArray(); $this->message = new Message(); $this->message->addFrom($this->from)->addTo($this->to)->setSubject($this->subject)->setBody($this->body); return $this; }