Reader Stacks

Sending Mail in Laravel Through Gmail SMTP

Gmail SMTP config for Laravel Mail, and why you need an App Password, not your normal Gmail password, once 2-Step Verification is on.

Sending Mail in Laravel Through Gmail SMTP

Gmail SMTP is a reasonable way to send mail from a low-volume Laravel app (testing, small internal tools) — for a production app with real send volume, a dedicated transactional mail provider (Postmark, SES, Mailgun) is a better fit, since Gmail's SMTP has sending limits not designed for application traffic.

.env configuration

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-address@gmail.com
MAIL_PASSWORD=your-16-character-app-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="your-address@gmail.com"
MAIL_FROM_NAME="${APP_NAME}"

You need an App Password, not your real Gmail password

If 2-Step Verification is enabled on the Google account (and it should be), your normal account password won't work for SMTP at all — Google requires a 16-character App Password generated specifically for this purpose, from the Google Account's Security settings under "App passwords." Using the real account password here either fails outright or, if somehow accepted, is a real credential-exposure risk if the .env file ever leaks.

Sending a test mail

use Illuminate\Support\Facades\Mail;
use App\Mail\WelcomeMail;

Mail::to('someone@example.com')->send(new WelcomeMail($user));

Config cache gotcha

If mail was working, then stops after you update .env, and you're running php artisan config:cache in this environment — the app is still using the previously cached config values, not your new ones. Run php artisan config:cache again (not just edit .env) any time mail settings change in an environment where config is cached.

Gmail's real limits

Gmail SMTP caps around 500 emails per day for a standard account (higher for Google Workspace) and can flag an app's sending pattern as suspicious well before that if the volume ramps up quickly. This is exactly why it's a fine choice for low-volume or dev/staging use, and the wrong choice for a real production app sending password resets, receipts, or notifications at scale.

Topics: APIs & Integrations