How to Configure Gmail SMTP in Laravel
I just wanted to share a little as well as my personal notes for the Gmail SMTP settings or configuration in the Laravel project for sending email notifications and the like. Actually, there are many ways to configure Laravel mail, such as using email hosting, but due to limited costs, some people choose to use Gmail because it’s free and of course they have an account, so it’s more efficient.
How to Configure Gmail SMTP in Laravel
First, please configure the .env file in our Laravel project, then adjust the requested data such as:
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremail@gmail.com
MAIL_PASSWORD=Gmail application password (not the Gmail password, OK)
MAIL_ENCRYPTION=plz
MAIL_FROM_ADDRESS=”emailkamu2@gmail.com”
MAIL_FROM_NAME=”${APP_NAME}”
More or less like the settings above for using the SMTP mail service from Gmail, to get the mail_password, please go to your Google account settings page, or Manage Google account. Go to the Security menu and two-step verification.
Make sure you have activated two-step verification, and when you enter the 2-step verification menu, there is a menu below Application Password. Please just create a new one with a free name as you wish, and click get password. So, the password you get from there is what you enter into your .env file.
Make sure the password is in the same order, without spaces or even – signs.
Closing
That’s a little information about how to configure Gmail SMTP in a Laravel project, I hope this helps. Maybe you are also interested in a guide on how to make local Laravel projects publicly accessible for free.