DEV Community

Cover image for How to send email using a Gmail account in laravel 12
Msh Sayket
Msh Sayket

Posted on

How to send email using a Gmail account in laravel 12

In this post, I will show you step by step how to send email using a Gmail account in laravel 12 application.

Laravel 12 provides an inbuilt mail configuration for sending emails. You can use several drivers for sending emails in laravel 12. You can use SMTP, Mailgun, Postmark, Amazon SES, and send email. Here in this example, we will use Google Gmail mailer driver for sending email.

How to send email using a Gmail account in laravel 12

Install Laravel 12

This step is not required; however, if you have not created the Laravel app, then you may go ahead and execute the below command:

laravel new example-app
Enter fullscreen mode Exit fullscreen mode

Step 2: Make Configuration

In the second step, you have to add the mail configuration. Set the mail driver as “gmail”, the mail host, mail port, mail username, and mail password. Laravel 12 will use these sender details for emails. You can simply add them as follows:

.env

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=mygoogle@gmail.com
MAIL_PASSWORD=rrnnucvnqlbsl
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=mygoogle@gmail.com
MAIL_FROM_NAME="${APP_NAME}"
Enter fullscreen mode Exit fullscreen mode

Make sure you have to enable Google security setting from your Gmail. Go to Google account and click on “Account”. Once you are on the “Account” page, click on “Security”. Scroll down to the bottom and you will find “Less secure app access” settings. Set it as ON. Read More from DevScriptSchool

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay