Configure Laravel email testing with SMTPBox
Configure Laravel SMTP settings, send a test message and diagnose cached configuration and queue-worker issues.
Configure your non-production environment
Create an inbox and generate an SMTP credential in SMTPBox. Put its username and password in your application's local or staging environment, with no spaces around the equals signs.
MAIL_MAILER=smtp
MAIL_SCHEME=smtp
MAIL_HOST=smtp.smtpbox.dev
MAIL_PORT=587
MAIL_USERNAME=your_inbox_username
MAIL_PASSWORD=your_inbox_password
MAIL_FROM_ADDRESS=hello@example.test
MAIL_FROM_NAME="Example app"The Laravel 12 and 13 skeletons read MAIL_SCHEME in config/mail.php. The SMTP transport upgrades with STARTTLS when supported. Older configurations commonly read MAIL_ENCRYPTION; set that to tls for port 587. Check the keys your own application actually reads. Remove an old MAIL_URL if it overrides the host and credentials.
See the official Laravel mail configuration. For implicit TLS use port 465 with the smtps scheme in configurations that support it.
Reload configuration and send a test
php artisan config:clear
php artisan queue:restart
php artisan tinkerIn Tinker, send a small message:
Illuminate\Support\Facades\Mail::raw('SMTPBox connection test', function ($message) {
$message->to('qa@example.test')->subject('Laravel SMTPBox test');
});Open the inbox associated with that SMTP credential. The message should show the subject and plain text above. Restart other long-running application processes that cache configuration if your deployment uses them.
Test mailables and notifications
Trigger the actual registration, reset or invoice action using a synthetic account. Run the queue worker if the mail is queued. Inspect the HTML, text and attachments, then compare the target URLs with your staging APP_URL.
Laravel mail fakes bypass SMTP. Keep them for fast unit tests; use a separate integration test without the fake when you intend to capture a real message. Read the Laravel testing workflow and API assertion pattern.
Resolve common errors
- 535: copy the inbox SMTP username and password again; account passwords and API keys do not work here.
- Timeout: check outbound access to port 587; try STARTTLS on 2525 if your host permits it.
- No message: check queue failures, cached configuration and the selected inbox.
Keep production mail configured to your delivery provider. SMTPBox captures rather than forwards email.
Updated