简体   繁体   中英

(Swift_TransportException(code: 0): Connection to tcp://server.example.com:465 Timed Out

We have changed the email server from a provider to another. The where sending with the old email settings but not with the new ones. I am not sure if it`s laravel server or email server.

I will use here my domain as: example.com

I have changed the new email settings in .env:

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

and when we send emails we get this exception in 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)

I have tried also with tls instead of ssl but the same error.

I have configure that email no-replay@example.com in thunderbird with the given settings from the provider and works.

Email settings:

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.

I am missing something ????

If you send your email from an gmail account then try this

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

If you do this in your gmail then you can send mail from your gmail account easily

In my case the error was misleading. It's wasn't a timeout but was caused by the wrong encryption setting.

In my case I needed to set MAIL_ENCRYPTION=ssl

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