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'),
            $encryptionType
        );
        $transport->setUsername($this->getMailConfig('smtp_username'));
        $transport->setPassword($this->getMailConfig('smtp_password'));

        return \Swift_Mailer::newInstance($transport);
    }