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

前端 未结 13 1186
别那么骄傲
别那么骄傲 2020-12-03 05:00

I can\'t figure for the life of me why exactly is it failing.. this is the exact error I am getting:

Fatal error: Uncaught exception \'Swift_TransportExcepti         


        
相关标签:
13条回答
  • 2020-12-03 05: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.

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

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

    In v 5.8.38, I set the env file as the following:

    MAIL_DRIVER=smtp
    MAIL_HOST=smtp.googlemail.com
    MAIL_PORT=465
    MAIL_USERNAME=mygmail@gmail.com
    MAIL_PASSWORD=difficultCombination
    MAIL_ENCRYPTION=ssl
    MAIL_FROM_NAME=myWebappName
    

    After doing php artisan config:clear, it worked well on a shard server.

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

    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.

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

    If you have hosted your website already it advisable to use the email or create an offical mail to send the email Let say your url is www.example.com. Then go to the cpanel create an email which will be send@example.com. Then request for the setting of the email. Change the email address to send@example.com. Then change your smtp which will be mail.example.com. The ssl will remain 465

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

    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.

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