From f409ad425e68e38adf8917f80769ea6af828f267 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 20 May 2017 20:25:16 +1000 Subject: [PATCH] Fix mail sending --- src/Mail/Mailer.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Mail/Mailer.php b/src/Mail/Mailer.php index ec79bfae7..4025d70dc 100644 --- a/src/Mail/Mailer.php +++ b/src/Mail/Mailer.php @@ -3,6 +3,7 @@ use Event; use Config; use Illuminate\Mail\Mailer as MailerBase; +use Illuminate\Contracts\Mail\Mailable as MailableContract; /** * Mailer class for sending mail. @@ -39,13 +40,16 @@ public function send($view, array $data = [], $callback = null) return; } + if ($view instanceof MailableContract) { + return $this->sendMailable($view); + } + /* * Inherit logic from Illuminate\Mail\Mailer */ list($view, $plain, $raw) = $this->parseView($view); $data['message'] = $message = $this->createMessage(); - $this->callMessageBuilder($callback, $message); if (is_bool($raw) && $raw === true) { $this->addContentRaw($message, $view, $plain); @@ -54,6 +58,12 @@ public function send($view, array $data = [], $callback = null) $this->addContent($message, $view, $plain, $raw, $data); } + call_user_func($callback, $message); + + if (isset($this->to['address'])) { + $this->setGlobalTo($message); + } + /* * Extensibility * $view - View code as a string @@ -70,16 +80,14 @@ public function send($view, array $data = [], $callback = null) /* * Send the message */ - $_message = $message->getSwiftMessage(); - $response = $this->sendSwiftMessage($_message); + $this->sendSwiftMessage($message->getSwiftMessage()); + $this->dispatchSentEvent($message); /* * Extensibility */ - $this->fireEvent('mailer.send', [$view, $message, $response]); - Event::fire('mailer.send', [$this, $view, $message, $response]); - - return $response; + $this->fireEvent('mailer.send', [$view, $message]); + Event::fire('mailer.send', [$this, $view, $message]); } /**