Skip to content

Commit

Permalink
Fix mail sending
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed May 20, 2017
1 parent 286dfbe commit f409ad4
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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]);
}

/**
Expand Down

0 comments on commit f409ad4

Please sign in to comment.