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

Auto-start the SMTP transport when sending a message #1126

Merged
merged 1 commit into from Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 itself 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