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
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() ;
}
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.
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.
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
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.