代码之家  ›  专栏  ›  技术社区  ›  calin24

(Swift_TransportException(代码:0):连接到tcp://server.example.com:465超时

  •  0
  • calin24  · 技术社区  · 6 年前

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

    我将在这里使用我的域名: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.
    

    我错过了什么????

    0 回复  |  直到 6 年前
        1
  •  0
  •   albus_severus    6 年前

    如果你从gmail帐户发送电子邮件,那么试试这个

    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.gmail.com
    MAIL_PORT=465
    MAIL_USERNAME=your_email (like abc@gmail.com)
    MAIL_PASSWORD=secret (when you create a app in your google account then  get a app secret)
    MAIL_ENCRYPTION=ssl
    
    

    如果你在gmail中这样做,那么你可以很容易地从gmail帐户发送邮件

    推荐文章