Swift_TransportException Connection could not be established with host smtp.gmail.com

点点圈 提交于 2019-11-27 13:32:16

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection refused #111]

Connection refused is a very explicit and clear error message. It means that the socket connection could not be established because the remote end actively refused to connect.

It's very unlikely that Google is blocking the connection.

It's very likely that your web hosting provider has firewall settings that block outgoing connections on port 465, or that they are blocking SMTP to Gmail. 465 is the "wrong" port for secure SMTP, though it is often used, and Gmail does listen there. Try port 587 instead. If the connection is still refused, call your host and ask them what's up.

remove from your config.yml spool: { type: memory }

Then you will be to add try catch like this

    try{
        $mailer = $this->getMailer();
        $response = $this->getMailer()->send($message);
    }catch(\Swift_TransportException $e){
        $response = $e->getMessage() ;
    }

tcp:465 was blocked. Try to add a new firewall rules and add a rule port 465. or check 587 and change the encryption to tls.

I had the same issue when I was using Godaddy web hosting and solved this by editing my .env file as,

MAIL_DRIVER=smtp
MAIL_HOST=XXXX.XXXX.in
MAIL_PORT=587
MAIL_USERNAME=dexxxxx
MAIL_PASSWORD=XXXXXXXX
MAIL_ENCRYPTION=tls

Where MAIL_HOST is your domain name from Godaddy, MAIL_USERNAME is your user name from Godaddy and MAIL_PASSWORD is your password from Godaddy.

I hope this may help you.

My solution was to change:

  'driver' => 'smtp',

to

 'driver' => 'mail',

In app/config/mail

Hope that helps

I had the same problem for a while, replacing: smtp.gmail.com with 173.194.65.108 actually worked for me!

In my case, I was using Laravel 5 and I had forgotten to change the mail globals in the .env file that is located in your directory root folder (these variables override your mail configuration)

   MAIL_DRIVER=smtp
   MAIL_HOST=smtp.gmail.com
   MAIL_PORT=465
   MAIL_USERNAME=yourmail@gmail.com
   MAIL_PASSWORD=yourpassword

by default, the mailhost is:

   MAIL_HOST=mailtraper.io

I was getting the same error but that worked for me.

I had the same issue and i manage to fix it by disabling my AVAST Anti Virus. As well as my AVAST extension in the browser. Antivirus sometimes blocks your application. :) I hope it helps to anyone.

firstly,check for gmail SMTP server . you should have to allow access for less secured apps without allowing swift mailer is not possible.for this login in your email account first then go into privacy settings and then click on sign and security then click on apps without access and then make on to less secure apps option then try mailer again, it will work then.

In my case, I had trouble with GoDaddy and SSL encryption.

Setting the encryption to Null and Port to 80 (Or any supportive port) did the job.

I just had this issue and solved it by editing mail.php under config folder. Usually when using shared hosting, they hosting company allows you to create an email such as

XXXX@yourdomainname.com

. So go to email settings under you shared hosting cpanel and add new email. Take that email and password and set it in the

mail.php.

It should work!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!