简体   繁体   English

Mautic 无法与 TLS 连接。 SMTP

[英]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.我正在开发一个项目,使用 Docker 容器在 AWS 的 Elastic Beanstalk 上自动部署和配置 Mautic 实例。 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."一切似乎都井井有条,但是当我单击 Mautic 配置的电子邮件设置中的“测试连接”时,我总是收到“无法使用 TLS 加密连接”。

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.我已经确保 OpenSSL 已安装并在 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. Mautic 正在使用 swiftmailer 发送电子邮件,所以我进入了他们的代码,并复制了他们用来测试的确切代码片段。 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.此脚本是从 AWS Elastic Beanstalk 服务器上的 docker 容器内部执行的。

So what am I missing?那么我错过了什么? Why is this failing me when testing through mautic?为什么在通过 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.测试脚本还使用 Mautic 实例正在使用的相同vendor文件夹,所以我知道它使用的是完全相同版本的 SwiftMailer。

Thanks谢谢

== ==

UPDATE 1更新 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.从 PHP 5.6 降级到 PHP 5.5 似乎解决了这个问题,但我不喜欢为了解决问题而降级 PHP 的想法。 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.我确实注意到这个问题,有人指出了 5.6 的解决方案,但它涉及编辑供应商文件,这对我不起作用,因为我试图自动化所有这些。

I spent half day to find out how to connect with Mautic 2.16.2 and PHP 7.1.我花了半天时间来了解如何与 Mautic 2.16.2 和 PHP 7.1 连接。

The problem is TLS version constant defined in SwiftMailer (STREAM_CRYPTO_METHOD_TLS_CLIENT).问题是 SwiftMailer (STREAM_CRYPTO_METHOD_TLS_CLIENT) 中定义的 TLS 版本常量。 For backwards compability it points to 1.0 v. of TLS.为了向后兼容,它指向 TLS 的 1.0 v.。 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 .您可以更改STREAM_CRYPTO_METHOD_TLS_CLIENTSTREAM_CRYPTO_METHOD_TLSv1_2_CLIENT (或其他版本)在/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php。

For further information check this SwiftMailer issue有关更多信息,请查看此 SwiftMailer 问题

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:最近解决了两件事:首先,更新到 2.0.0 版本,然后我发现(虽然不确定是否正确)cron 作业必须在我的主机(godaddy 服务器)上以非常特定的顺序排列,没有最后的代码很糟糕,像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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