Tuesday, 23 November 2021

Laravel how to send email with smtp with google, and unitTest

 // https://stackoverflow.com/questions/32515245/how-to-to-send-mail-using-gmail-in-laravel

Laravel to use facades\Mail in laravel with google smtp , 

first in .env configure (config/mail.php uses these values)

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

// Next in Google, turn on less secure app
https://help.dreamhost.com/hc/en-us/articles/115001719551-Troubleshooting-GMAIL-SMTP-authentication-errors


// NOTE: when testing mail():: send with Laravel phpUnit, no actual email will be send . Only return true or throw exception.
To see actual effect, has to test with net work request or curl

No comments:

Post a Comment