I'm posting because I've already gone through the solutions posted in other questions on here but they haven't helped.
What I am trying to do is send email using Swiftmailer through Google Apps for Business Gmail but I keep getting this error:
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
I know the code is fine because it works on my local machine but not on the production server.
What I have tried so far:
Configuration:
# Swiftmailer Configuration
swiftmailer:
transport: smtp
encryption: ssl
auth_mode: login
host: smtp.gmail.com
username: contact@mydomain.com
password: applicationspecificpassword
port: 465
What else can I try? Could this be a DNS issue since I am using Gmails SMTP MX records instead of the servers.
The following steps worked for me :
Check if httpd_can_sendmail is on , run this getsebool httpd_can_sendmail
setsebool -P httpd_can_sendmail 1
Check also if httpd_can_network_connect is on, run getsebool httpd_can_network_connect
setsebool -P httpd_can_network_connect 1
'host' => '64.233.166.108'
'port' => '465'
I'm using Centos
替换: smtp.gmail.com
与173.194.65.108
实际上对我173.194.65.108
!
If you ever want to return to using Gmail, I've just faced the same problem - the code worked on my local machine but not on a real server - and think I've figured out what is causing it (at least in my case).
It appears that if a server supports IPv6 and IPv4, the server's domain resolves as its IPv6 version so PHP tries to connect to that. But I was finding that smtp.gmail.com did not respond, so after 30 seconds the script just gave up and timed out. You would think that PHP would try IPv4 after IPv6 failed, but no.
So when I swapped in the IPv4 address of smtp.gmail.com (got by ping-ing it), everything worked fine and the email sent. It's not ideal using an IP in place of a domain since it could change, but at least it saves digging up the rest of the server's floorboards :)
只需将74.125.130.108 smtp.gmail.com
添加到服务器的主机文件
For me the issue was i that I used tls encryption,here are the ports for TLS and SSL. Don`t forget to reboot after changing the env file.
smtp.gmail.com --- SSL --- 465
smtp.gmail.com --- StartTLS --- 587
Also,you need to change the security of your google account
我在Swiftmailer Gmail Connection timed out #110中发布了一个解决方案,您可以在其中使用 IPv4 或 IPv6。
Config working for me:
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: my_email@gmail.com
mailer_password: my_pass
mailer_encryption: ssl
mailer_auth_mode: login
mailer_port: 465
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.