Laravel
Point Laravel's mailer at a sandbox with five environment variables — no package, no code change.
Before you start
- PHP 8.1 or later
- Laravel 9, 10, 11 or 12
1Set the mail variables
Laravel ships with an SMTP mailer, so there is nothing to install. Replace the mail block of your .env — keep the rest of the file as it is.
# .env MAIL_MAILER=smtp MAIL_HOST=smtp.mailclutch.com MAIL_PORT=587 MAIL_USERNAME=mc_0000000000000000 MAIL_PASSWORD=pw_0000000000000000 MAIL_FROM_ADDRESS="staging@example.com" MAIL_FROM_NAME="${APP_NAME}"
Then clear the cached config, or the old values will keep being used: php artisan config:clear.
2Send a test message
From a shell, with php artisan tinker:
Mail::raw('Hello from Laravel.', function ($message) { $message->to('anyone@example.com')->subject('Sandbox check'); });
Or run whatever already sends mail in your application — a password reset, an order confirmation. Nothing is delivered onward, so real addresses are safe.
Watch it land
Open the sandbox and the message is there — rendered HTML, plain text, raw source, attachments, and the SPF, DKIM and DMARC verdicts. It updates live, so you can leave it open next to your terminal.
Nothing is ever delivered onward, whatever address you send to; claim the inbox with an account and it stays.
Awaiting your email
Send from any address; it stops here rather than going onward. The inbox keeps what it catches for 24 hours.
What usually goes wrong
Queued mail never arrives
Anything sent through
Mail::queue()or aShouldQueuemailable waits for a worker. Runphp artisan queue:work, or setQUEUE_CONNECTION=syncin staging.Encryption
Laravel 11 and 12 negotiate STARTTLS on port 587 by themselves. On Laravel 10 and earlier, add
MAIL_ENCRYPTION=tls— or use port 465 withMAIL_ENCRYPTION=ssl.
Other stacks
The same four values in another dialect. Every guide below is filled in with the sandbox pair at the top of this page.
Frameworks and languages
- SymfonyOne MAILER_DSN
- DjangoFive settings, nothing installed
- RailsAction Mailer smtp_settings
- Node.jsA Nodemailer transport
- Next.jsRoute Handler or Server Action
- Gonet/smtp, standard library
- SpringFive Spring Boot properties
- JavaJakarta Mail, no framework
- .NETMailKit: connect, auth, send
- PHPPHPMailer, no framework
- Pythonsmtplib, standard library
- Rustlettre over a STARTTLS relay