Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
added auto-start of the transport when sending a message
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 11, 2018
1 parent dd8f20b commit 2ccc29c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/classes/Swift/Mailer.php
Expand Up @@ -60,6 +60,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
{
$failedRecipients = (array) $failedRecipients;

// FIXME: to be removed in 7.0 (as transport must now start themselves on send)
if (!$this->transport->isStarted()) {
$this->transport->start();
}
Expand Down
2 changes: 2 additions & 0 deletions lib/classes/Swift/Transport.php
Expand Up @@ -61,6 +61,8 @@ public function ping();
* Recipient/sender data will be retrieved from the Message API.
* The return value is the number of recipients who were accepted for delivery.
*
* This is the responsibility of the send method to start the transport if needed.
*
* @param Swift_Mime_SimpleMessage $message
* @param string[] $failedRecipients An array of failures by-reference
*
Expand Down
4 changes: 4 additions & 0 deletions lib/classes/Swift/Transport/AbstractSmtpTransport.php
Expand Up @@ -177,6 +177,10 @@ public function isStarted()
*/
public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
{
if (!$this->isStarted()) {
$this->start();
}

$sent = 0;
$failedRecipients = (array) $failedRecipients;

Expand Down

0 comments on commit 2ccc29c

Please sign in to comment.