From 3172b0f1d899ae9d7e00855a01e76b415a7d5f17 Mon Sep 17 00:00:00 2001 From: James Inman Date: Wed, 15 Oct 2014 10:55:09 +0100 Subject: [PATCH] Adding check for a valid encryption context to MailerFactory. --- PHPCI/Helper/MailerFactory.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/PHPCI/Helper/MailerFactory.php b/PHPCI/Helper/MailerFactory.php index b0ec4860..4eb57c13 100644 --- a/PHPCI/Helper/MailerFactory.php +++ b/PHPCI/Helper/MailerFactory.php @@ -28,11 +28,19 @@ class MailerFactory */ public function getSwiftMailerFromConfig() { + $encryptionType = $this->getMailConfig('smtp_encryption'); + + // Workaround issue where smtp_encryption could == 1 in the past by + // checking it is a valid transport + if ($encryptionType && !in_array($encryptionType, stream_get_transports())) { + $encryptionType = null; + } + /** @var \Swift_SmtpTransport $transport */ $transport = \Swift_SmtpTransport::newInstance( $this->getMailConfig('smtp_address'), $this->getMailConfig('smtp_port'), - $this->getMailConfig('smtp_encryption') + $encryptionType ); $transport->setUsername($this->getMailConfig('smtp_username')); $transport->setPassword($this->getMailConfig('smtp_password'));