简体   繁体   中英

how to send email in laravel 5.4 on live server Swift_TransportException Connection could not be established with host smtp.gmail.com

I am trying to send email from laravel 5.4 application and using smtp.gmail.com host, its working fine on localhost but not on live server. how to send email from laravel application without using mailtrap, by using smtp.gmail.com. may I know what changes I have to do in .env and mail.php file? Please check the code of my .env and mail.php file and also find the screenshot of error I am getting

在此处输入图片说明

Make your .env file to something like this:

MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your@gmail.com
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls

For app password Read Under the Section How to generate an App password:

After change of .env must be clear cache: php artisan config:cache

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM