Swiftmailer: Connection could not be established with host smtp.gmail.com [Connection timed out #110]

后端 未结 8 1342
执念已碎
执念已碎 2020-12-05 03:27

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

相关标签:
8条回答
  • 2020-12-05 03:33

    just add 74.125.130.108 smtp.gmail.com to server's hosts file

    0 讨论(0)
  • 2020-12-05 03:34

    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 :)

    0 讨论(0)
  • 2020-12-05 03:37

    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
    
    0 讨论(0)
  • 2020-12-05 03:40

    Replacing: smtp.gmail.com with 173.194.65.108 actually worked for me!

    0 讨论(0)
  • 2020-12-05 03:41

    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

    0 讨论(0)
  • 2020-12-05 03:46

    The following steps worked for me :

    1. Check if httpd_can_sendmail is on , run this getsebool httpd_can_sendmail

      • When you get: httpd_can_sendmail --> off , run setsebool -P httpd_can_sendmail 1
      • When you get: httpd_can_sendmail --> on that's fine move on step 2.
    2. Check also if httpd_can_network_connect is on, run getsebool httpd_can_network_connect

      • When you get httpd_can_network_connect --> off run setsebool -P httpd_can_network_connect 1
      • When you get: httpd_can_network_connect --> on that's fine move on step 3.
    3. Use the following settings for smtp : 'host' => '64.233.166.108' 'port' => '465'

    I'm using Centos

    0 讨论(0)
提交回复
热议问题