mercredi 22 juin 2016

Using gmail smtp via Laravel: [Connection timed out #110]

Before doing down vote or making it duplicate, please read the description.

I know this question is asked many times and have different solutions and I have tried all but no one has worked. This is my settings.

 MAIL_DRIVER=smtp
 MAIL_HOST=smtp.gmail.com
 MAIL_PORT=465
 MAIL_USERNAME=abc@mydomain.com
 MAIL_PASSWORD=mypassword
 MAIL_ENCRYPTION=ssl

And application is currently running on Centos 7 OS.

I always get

Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [Connection timed out #110]

at Swift_Transport_StreamBuffer->initialize(array('protocol' => 'ssl', 'host' => 'smtp.gmail.com', 'port' => '465', 'timeout' => '30', 'blocking' => '1', 'tls' => false, 'type' => '1', 'stream_context_options' => array())) in AbstractSmtpTransport.php line 113

I have tried all solutions, by Replacing: smtp.gmail.com with 173.194.65.108, or replacing smtp.gmail.com by gmail-smtp-msa.l.google.com. When I do these two steps, it got server not found error.

If I change mail driver from smtp to sendmail or mail, no error is thrown but no email is sent.

If I use ip address of smtp.gmail.com, I got same result. If I change port from 465 to 587 and encryption from ssl to tls, nothing happens.

I have also created a file in etc/gai.conf and put precedence ::ffff:0:0/96 100. It worked one time. But later after two hours, it stopped working and started throwing same error.

I have also tried using my gmail id but all in vain.

The only solution that I couldn't be able to test is verifying httpd_can_sendmail as whenever I run command getsebool httpd_can_sendmail I get getsebool: SELinux is disabled. Is this the problem or is there any other way to get it fixed?

Aucun commentaire:

Enregistrer un commentaire