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_USERNAME=usergmail@gmail.com
MAIL_PASSWORD=the_above_password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=fromaddress@gmail.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.
Send Email In PHP With PHPMailer
Hope you enjoyed the article. Please share it with your friends.
Lazy Load YouTube And Other Videos In Website
Simple Way To Create Resourceful API Controller In Laravel
Install Apache Web Server On Ubuntu 20.04 / Linux & Manage It
URL Redirects From Called Functions In Laravel
Search Engine Optimization Concepts
Test Your Local Developing Laravel Web Application From Phone Browser Without Any Software
Testing Laravel Emails With MailHog
Localization In Laravel REST API
Proper Way To Validate MIME Type Of Files While Handling File Uploads In PHP
Install Letsencrypt SSL Certificate for RabbitMQ Server and RabbitMQ Management Tool