How to to send mail using gmail in Laravel? How to to send mail using gmail in Laravel? laravel laravel

How to to send mail using gmail in Laravel?


first login to your gmail account and under My account > Sign In And Security > Sign In to google, enable two step verification, then you can generate app password, and you can use that app password in .env file.

Your .env file will then look something like this

MAIL_DRIVER=smtpMAIL_HOST=smtp.gmail.comMAIL_PORT=587MAIL_USERNAME=myemail@gmail.comMAIL_PASSWORD=apppasswordMAIL_ENCRYPTION=tls

Don't forget to run php artisan config:cache after you make changes in your .env file.


Try using sendmail instead of smtp driver (according to these recommendations: http://code.tutsplus.com/tutorials/sending-emails-with-laravel-4-gmail--net-36105)

MAIL_DRIVER=sendmailMAIL_HOST=smtp.gmail.comMAIL_PORT=587MAIL_USERNAME=your@gmail.comMAIL_PASSWORD=apppasswordMAIL_ENCRYPTION=tls


All you have to do is just edit in you.env file, that's it.

MAIL_DRIVER=smtpMAIL_HOST=smtp.gmail.comMAIL_PORT=465MAIL_USERNAME=<your_email_address>MAIL_PASSWORD=<your_gmail_app_password_>MAIL_ENCRYPTION=ssl

for app password goto https://support.google.com/accounts/answer/185833?hl=en

and genearate your app pasword and save for future use. because once you generate app password you cannot re-edit password or change same app password.(you can create multiple app password)