Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:

  • Enabled OpenSSL.
  • Unblocked account from Google captcha.
  • Used an Application Specific Password.
  • Whitelisted Gmail SMTP IP addresses

Configuration:

# Swiftmailer Configuration
swiftmailer:
    transport:  smtp
    encryption: ssl
    auth_mode:  login
    host:       smtp.gmail.com
    username:   [email protected]
    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.

like image 418
Jonathan Avatar asked Aug 27 '14 00:08

Jonathan


2 Answers

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

like image 104
ikuchris Avatar answered Sep 23 '22 02:09

ikuchris


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

like image 35
Mohammad Anini Avatar answered Sep 21 '22 02:09

Mohammad Anini