Loading src/Plugin/Mail/SMTPMailSystem.php +29 −2 Original line number Diff line number Diff line Loading @@ -84,6 +84,13 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { */ protected $mimeTypeGuesser; /** * The SMTP object, stored between calls when keep alive is enabled. * * @var PHPMailer\PHPMailer\SMTP */ protected $persistentSmtp; /** * Constructs a SMPTMailSystem object. * Loading Loading @@ -211,8 +218,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { // Optionally reroute all emails to a single address. list($to, $headers) = $this->applyRerouting($to, $headers); // Create a new PHPMailer object - autoloaded from registry. $mailer = new PHPMailer(TRUE); $mailer = $this->getMailer(); // Use email.validator due to different validation standard by PHPMailer. $mailer::$validator = [$this->emailValidator, 'isValid']; Loading Loading @@ -861,4 +867,25 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { return [$new_to, $new_headers]; } /** * Get (and, if applicable, build) the PHPMailer object. * * @return \PHPMailer\PHPMailer\PHPMailer */ protected function getMailer() { if ($this->smtpConfig->get('smtp_keepalive')) { $mailer = new PHPMailer(TRUE); if ($this->persistentSmtp) { $mailer->setSMTPInstance($this->persistentSmtp); } else { $this->persistentSmtp = $mailer->getSMTPInstance(); } return $mailer; } else { return new PHPMailer(TRUE); } } } Loading
src/Plugin/Mail/SMTPMailSystem.php +29 −2 Original line number Diff line number Diff line Loading @@ -84,6 +84,13 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { */ protected $mimeTypeGuesser; /** * The SMTP object, stored between calls when keep alive is enabled. * * @var PHPMailer\PHPMailer\SMTP */ protected $persistentSmtp; /** * Constructs a SMPTMailSystem object. * Loading Loading @@ -211,8 +218,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { // Optionally reroute all emails to a single address. list($to, $headers) = $this->applyRerouting($to, $headers); // Create a new PHPMailer object - autoloaded from registry. $mailer = new PHPMailer(TRUE); $mailer = $this->getMailer(); // Use email.validator due to different validation standard by PHPMailer. $mailer::$validator = [$this->emailValidator, 'isValid']; Loading Loading @@ -861,4 +867,25 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface { return [$new_to, $new_headers]; } /** * Get (and, if applicable, build) the PHPMailer object. * * @return \PHPMailer\PHPMailer\PHPMailer */ protected function getMailer() { if ($this->smtpConfig->get('smtp_keepalive')) { $mailer = new PHPMailer(TRUE); if ($this->persistentSmtp) { $mailer->setSMTPInstance($this->persistentSmtp); } else { $this->persistentSmtp = $mailer->getSMTPInstance(); } return $mailer; } else { return new PHPMailer(TRUE); } } }