Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use SwiftMailer antiflood plugin to reconnect after multiple emails sent
  • Loading branch information
tomneedham committed Jun 21, 2017
commit 58d4ece80c7d47e8c2efd8760b8d8bafbc3cc062
25 changes: 16 additions & 9 deletions lib/private/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ public function send(Message $message) {

$mailer = $this->getInstance();

// Enable logger if debug mode is enabled
if($debugMode) {
$mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
}

$mailer->send($message->getSwiftMessage(), $failedRecipients);

// Debugging logging
Expand Down Expand Up @@ -154,19 +148,32 @@ protected function getInstance() {

switch ($this->config->getSystemValue('mail_smtpmode', 'php')) {
case 'smtp':
$this->instance = $this->getSMTPInstance();
$instance = $this->getSMTPInstance();
break;
case 'sendmail':
// FIXME: Move into the return statement but requires proper testing
// for SMTP and mail as well. Thus not really doable for a
// minor release.
$this->instance = \Swift_Mailer::newInstance($this->getSendMailInstance());
$instance = \Swift_Mailer::newInstance($this->getSendMailInstance());
break;
default:
$this->instance = $this->getMailInstance();
$instance = $this->getMailInstance();
break;
}

// Register plugins

// Enable logger if debug mode is enabled
if($this->config->getSystemValue('mail_smtpdebug', false)) {
$mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
$instance->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
}

// Enable antiflood on smtp connection (defaults to 100 mails before reconnect)
$instance->registerPlugin(new \Swift_Plugins_AntiFloodPlugin());

$this->instance = $instance;

return $this->instance;
}

Expand Down