Generate Gmail SMTP Credentials(with images)

Talha Maqsood
2 min readOct 10, 2020

--

6 very easy steps to send mail using Gmail SMTP in laravel 8.9.0:

1- Open your Google account settings

2- Click on the “2-Step Verification”

gmail account settings

then click on “Get Started” and enter your google password

2 step varification

3- Verify your phone number

verify phone number

and click on “Turn On” 2 step verification

turn on two step verification

4- After turning on the two-step verification turn back to the security section click on “App passwords” and enter your Google password

5- Click on the select app dropdown and select other (Custom name)

app password setting

6- Now type the name of your app/device

app name / device name

7- It will generate a 16-digit password and copy the password for later use

8- Open the .env file of your project

9- Convert this:

MAIL_MAILER=smtp

MAIL_HOST=smtp.mailtrap.io

MAIL_PORT=2525

MAIL_USERNAME=null

MAIL_PASSWORD=null

MAIL_ENCRYPTION=null

MAIL_FROM_ADDRESS=null

MAIL_FROM_NAME=”${APP_NAME}”

With this:

MAIL_MAILER=smtp

MAIL_HOST=smtp.gmail.com

MAIL_PORT=465

MAIL_USERNAME=your-gmail-account@gmail.com

MAIL_PASSWORD=your-app-password (16 digits)

MAIL_ENCRYPTION=ssl

#MAIL_FROM_ADDRESS=null

#MAIL_FROM_NAME=”${APP_NAME}”

The Gmail SMTP is done and there is no need to change anything else.

I hope it helps!

--

--

Talha Maqsood

Crafting next-level software experiences with Node.js, Laravel, and Blockchain - all while making the complex seem effortless.