diff --git a/src/Illuminate/Mail/Mailer.php b/src/Illuminate/Mail/Mailer.php index 03a9bd23d514..94f91dda225c 100755 --- a/src/Illuminate/Mail/Mailer.php +++ b/src/Illuminate/Mail/Mailer.php @@ -428,8 +428,8 @@ protected function createMessage() */ protected function sendSwiftMessage($message) { - if ($this->events) { - $this->events->dispatch(new Events\MessageSending($message)); + if (! $this->shouldSendMessage($message)) { + return; } try { @@ -439,6 +439,23 @@ protected function sendSwiftMessage($message) } } + /** + * Determines if the message can be sent. + * + * @param \Swift_Message $message + * @return bool + */ + protected function shouldSendMessage($message) + { + if (! $this->events) { + return true; + } + + return $this->events->until( + new Events\MessageSending($message) + ) !== false; + } + /** * Force the transport to re-connect. *