简体   繁体   中英

Mautic unable to connect with TLS. SMTP

I'm stuck on this one. I'm working on a project to automatically deploy and configure Mautic instances on AWS's Elastic Beanstalk using Docker containers. Everything appears to be in order, but when I click the "Test Connection" in the email settings of Mautic's configuration, I always get "Unable to connect with TLS encryption."

If I don't use any encryption, I'm able to connect just fine and send emails. So it's not a blocked port issue or bad credentials.

I've made sure OpenSSL is installed and running in PHP.

Mautic is using swiftmailer to send emails, so I went into their code, and copied the exact snippet of code they use to test. I inserted this into a test script like so, and ran it.

<?php
require_once __DIR__ . '/vendor/autoload.php';
try {
$mailer = new \Swift_SmtpTransport('...', 587, 'tls');
$mailer->setUsername('...');
$mailer->setPassword('...');

$mailer->start();
die('hello');
}
catch(Exception $e){
echo $e->getMessage();
}

That works fine. I went so far as adding the rest of the code needed to send the email, and it came to my mailbox just fine. This script was executed from inside the docker container that's on the AWS Elastic Beanstalk server.

So what am I missing? Why is this failing me when testing through mautic?

The test script also uses the same vendor folder that the Mautic instance is using so I know it's using the exact same version of SwiftMailer.

Thanks

==

UPDATE 1

Downgrading to PHP 5.5 from PHP 5.6 seems to have resolved this issue, but I don't like the idea of downgrading PHP just to solve a problem. I got the idea from this issue

So if anyone has a better solution, I'm still open. I do notice in the issue, someone has pointed out a solution for 5.6, but it involves editing vendor files, which doesn't work for me since I'm trying to automate all of this.

I spent half day to find out how to connect with Mautic 2.16.2 and PHP 7.1.

The problem is TLS version constant defined in SwiftMailer (STREAM_CRYPTO_METHOD_TLS_CLIENT). For backwards compability it points to 1.0 v. of TLS. You can change STREAM_CRYPTO_METHOD_TLS_CLIENT to STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT (or other version) in /mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php .

For further information check this SwiftMailer issue

I had a simular problem. Recently got solved with two things: First, updated to the 2.0.0 release, then I figured out (although not sure if true) that the cron jobs had to be in a very specific order at my host (godaddy server) with none of the doohicky code at the end, like this:

mautic:campaigns:trigger mautic:campaigns:rebuild mautic:iplookup:download mautic:emails:send mautic:email:fetch mautic:segments:update

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM