Good content takes time and effort to come up with.
Please consider supporting us by just disabling your AD BLOCKER and reloading this page again.
You will learn how to generate the Gmail App password for sending SMTP mails in a simple way. Earlier we had to compromise on security but now its a good initiative from Google to make more secured apps.
We will be covering the following topics
Let's start with generating the APP password.
First, you need to login to your GMAIL
1 (Profile) - On right top corner click on your profile pic
2 (Mange Your Google Account) - Now click on Manage Your Google Account button. Which you take you to Gmail settings pages as shown below
1 (Security) - Make sure your have selected Security link on the left sidebar
2 (Signing To Google Section) - Now scroll to Signing In To Google section
3 (2 Step Verification) - Make sure your 2 - Step Verification is enabled. If not then please go ahead and add 2 Step Verification details. This is very important to secure your Gmail from unauthorized persons.
4 (App Password) - Now click on App Passwords which will take you to the following section
1 (App) - Select the Mail app
2 (Select Device) - Other and then add any custom name
3 (Generate) - Click on Generate button to generate your Gmail App Password
Once the Gmail App Password is generated successfully then you will get the pop up similar to the above image with a password. Make sure to copy and save.
Now looking at the above stuff your SMTP credentials will be similar to that of the following
MAIL_MAILER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=465 MAIL_USERNAMEfirstname.lastname@example.org MAIL_PASSWORD=the_above_password MAIL_ENCRYPTION=ssl MAIL_FROM_ADDRESSemail@example.com MAIL_FROM_NAME=sender_name
The above is how your credentials will look like. Don't worry, the above is how your
.env file looks like. You can use them with constants or directly add in the code.
NOTE: For the sake of security its best to add in .env file or some config file which won't be added to public available repositories.
l have already written a PHP article on how to send the SMTP mails kindly check it out.
Hope you enjoyed the article. Please share it with your friends.