php - (Swift_TransportException(代码 : 0): Connection to tcp://server. example.com:465 超时

标签 php laravel

我们已将电子邮件服务器从一个提供商更改为另一个提供商。使用旧电子邮件设置而不是新电子邮件设置的发送位置。我不确定它是 laravel 服务器还是电子邮件服务器。

我将在这里使用我的域名:example.com

我已经在 .env 中更改了新的电子邮件设置:

MAIL_DRIVER=smtp
MAIL_HOST=server.example.com
MAIL_PORT=465
MAIL_USERNAME=no-reply@example.com
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=ssl

当我们发送电子邮件时,我们在 laravel.log 中得到这个异常

production.ERROR: Connection to tcp://server.example.com:465 Timed Out {"exception":"[object] (Swift_TransportException(code: 0): Connection to tcp://server.example.com:465 Timed Out at /var/www/example.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:473, Swift_IoException(code: 0): Connection to tcp://server.example.com:465 Timed Out at /var/www/example.com/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:166)

我也尝试过使用 tls 而不是 ssl 但同样的错误。

我已经使用提供商的给定设置在 thunderbird 中配置了电子邮件 no-replay@example.com 并且可以正常工作。

电子邮件设置:

incoming: IMAP server.example.com 993 SSL/TLS Encrypted password 

outgoing: SMTP server.example.com 465 SSL/TLS Encrypted password

username (email address) and password.

我错过了什么????

最佳答案

在我的案例中,错误具有误导性。这不是超时,而是由错误的加密设置引起的。

在我的例子中,我需要设置 MAIL_ENCRYPTION=ssl

关于php - (Swift_TransportException(代码 : 0): Connection to tcp://server. example.com:465 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57632616/

相关文章:

php - Zend 框架 2 中的 Zend\ServiceManager\Exception\ServiceNotFoundException

php - MySQL 查询委托(delegate)/传输

数组中的php函数

php - 分页页面 ID 有问题

php - 使用 PHP 从 MySQL 选择并回显单个字段

php - Laravel - 从表中选择所有内容以及先前 SELECT 的结果

mysql - Eloquent belongsToMany 和三表(包括 Pivot)

php - Laravel Eloquent 验证插入异常?

laravel - 使用 PHP Buildpack 安排 CronJobs

php - 无法扫描里面的类/IlluminateQueueClosure.php