Skip to content

Commit

Permalink
Improve the Mail Service
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckyCyborg committed May 11, 2018
1 parent 2669e57 commit 71b463c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Application extends Container implements ResponsePreparerInterface
*
* @var string
*/
const VERSION = '4.0.55';
const VERSION = '4.0.56';

/**
* Indicates if the application has "booted".
Expand Down
33 changes: 16 additions & 17 deletions src/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ public function plain($view, array $data, $callback)
*/
public function send($view, array $data, $callback)
{
$this->forceReconnection();

// First we need to parse the view, which could either be a string or an array
// containing both an HTML and plain text versions of the view which should
// be used when sending an e-mail. We will extract both of them out here.
Expand All @@ -172,18 +170,6 @@ public function send($view, array $data, $callback)
$this->sendSwiftMessage($message);
}

/**
* Force the transport to re-connect.
*
* This will prevent errors in daemon queue situations.
*
* @return void
*/
protected function forceReconnection()
{
$this->getSwiftMailer()->getTransport()->stop();
}

/**
* Queue a new e-mail message for sending.
*
Expand Down Expand Up @@ -362,10 +348,23 @@ protected function sendSwiftMessage($message)
$this->events->dispatch('mailer.sending', array($message));
}

if (! $this->pretending) {
if ($this->pretending) {
// In pretending mode we will log the message if the logger is available.

if (isset($this->logger)) {
$this->logMessage($message);
}

return;
}

try {
$this->swift->send($message, $this->failedRecipients);
} else if (isset($this->logger)) {
$this->logMessage($message);
}
finally {
$transport = $this->swift->getTransport();

$transport->stop();
}
}

Expand Down

0 comments on commit 71b463c

Please sign in to comment.