Laravel email testing

Laravel email testing without the risk

Point your Laravel app's SMTP at Maildog's email sandbox and every outbound message — welcome emails, password resets, queued Mailables, Markdown templates — lands in a private inbox instead of a real user's. Inspect the HTML, raw headers, and SPF/DKIM/DMARC results in seconds, then ship with confidence.

Testing Laravel email safely is hard

Email is one of the easiest things to get wrong in a Laravel project — and one of the hardest to test safely. If you build SaaS apps, internal tools, or developer products, these pain points will feel familiar.

Testing the Mail facade is awkward

Mail::fake() is great for assertions in PHPUnit, but it tells you nothing about how the email actually looks. You can assert a Mailable was queued, yet never see the rendered HTML, the subject line, or whether your CTA button survived the inlining process.

Catching outbound mail is risky

Without a sandbox, a misconfigured MAIL_MAILER or a forgotten seed file can fire thousands of real emails from a staging environment. One bad migration that loops over User::all() and your transactional reputation is gone.

Accidentally emailing real users

Restoring a production database dump into staging is routine — and dangerous. Real addresses sitting in your users table mean any test send can hit actual customers.

Markdown mailables are painful to debug

Laravel's Markdown mailables compile through Blade components and CSS inlining. A broken @component('mail::button') or a missing theme often only shows up in the final rendered output — which you can't see without actually sending the mail somewhere.

Maildog captures every Laravel email

Maildog is an email sandbox and testing platform that captures every message your Laravel application sends, so nothing reaches a real inbox during development or staging. You change four environment variables. Laravel's existing Mail driver does the rest — no new package, no code changes to your Mailables.

Capture all SMTP traffic. Maildog runs a real SMTP server (a fake SMTP server, from your app's perspective) that accepts every connection but never delivers downstream. Your welcome, password.reset, and queued notification emails all land in a sandbox inbox you control.

Inspect the full message. For every captured email you get the rendered HTML preview, a plain-text view, the raw source, and a complete dump of headers — Message-ID, Content-Type, MIME boundaries, and custom X- headers added by your app or middleware.

Validate authentication. Maildog checks SPF, DKIM, and DMARC alignment against each message so you catch signing and policy problems in staging — long before they hurt deliverability in production.

Isolate per environment. Spin up separate sandbox inboxes for local, CI, and staging. Each environment gets its own SMTP credentials, so a developer's laptop and your GitHub Actions pipeline never cross streams.

Key features

Email sandbox for every environment

A dedicated, isolated inbox that captures 100% of the email your Laravel app generates. Give local development, CI, and staging each their own sandbox with unique SMTP credentials, so test traffic never mixes and real users are never reachable.

Real SMTP & fake SMTP server

Maildog speaks standard SMTP, so it behaves like a real mail server to Laravel's Symfony Mailer transport — but acts as a fake SMTP server that traps everything. No DNS, no MX records, no risk of downstream delivery. Point Laravel at the host and port and you are testing in minutes.

Deep email inspection & debugging

See exactly what your users would have seen. Render the HTML, switch to plain text, view the raw RFC 822 source, and read every header. Track down a broken Markdown mailable, a missing from address, or a malformed Content-Type without guesswork.

SPF, DKIM & DMARC validation

Every captured message is checked for SPF, DKIM signature validity, and DMARC alignment. Catch unsigned mail and authentication gaps in staging so your transactional email reaches the inbox, not the spam folder, in production.

Developer-friendly transactional email API

Beyond SMTP, Maildog exposes a clean transactional email API. Fetch captured messages, assert on subjects and recipients in automated tests, and wire email assertions into CI — all with simple JSON endpoints. When you're ready for production sending, the same API delivers real mail.

Inbound email testing

Need to test webhooks that parse incoming mail — support inboxes, reply-by-email, or +tag routing? Maildog's inbound email testing lets you receive and inspect inbound messages and exercise your parsing logic end to end.

Set up Laravel email testing in minutes

A complete, technically correct setup for Laravel 10 and 11. You only need to update your .env file and confirm config/mail.php reads from it — then send a Mailable as you normally would.

.envenv
MAIL_MAILER=smtp
MAIL_HOST=mail.maildog.io
MAIL_PORT=587
MAIL_USERNAME=your_sandbox_username
MAIL_PASSWORD=your_sandbox_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
config/mail.phpphp
// config/mail.php

'default' => env('MAIL_MAILER', 'smtp'),

'mailers' => [
    'smtp' => [
        'transport'  => 'smtp',
        'host'       => env('MAIL_HOST', '127.0.0.1'),
        'port'       => env('MAIL_PORT', 2525),
        'encryption' => env('MAIL_ENCRYPTION', 'tls'),
        'username'   => env('MAIL_USERNAME'),
        'password'   => env('MAIL_PASSWORD'),
        'timeout'    => null,
    ],
],
terminalbash
php artisan make:mail OrderShipped --markdown=emails.orders.shipped
app/Mail/OrderShipped.phpphp
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class OrderShipped extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(public string $orderNumber)
    {
    }

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: "Your order {$this->orderNumber} has shipped",
        );
    }

    public function content(): Content
    {
        return new Content(
            markdown: 'emails.orders.shipped',
        );
    }
}
send the Mailablephp
use App\Mail\OrderShipped;
use Illuminate\Support\Facades\Mail;

Mail::to('customer@example.com')->send(new OrderShipped('A-1042'));

// The message appears instantly in your Maildog sandbox inbox.
// Preview the rendered HTML, the plain-text alternative, the raw
// source and headers, and the SPF / DKIM / DMARC results.
// customer@example.com is never actually contacted.

// Testing queued Mailables? Add "implements ShouldQueue" to the
// class and run: php artisan queue:work — the message still lands
// in Maildog, confirming worker, serialization, and queue connection.

Why developers choose Maildog

Faster debugging

Stop adding dd($mailable->render()) or squinting at storage/logs/laravel.log. See the real rendered email and its headers immediately, and fix Markdown, layout, and header issues in one pass.

Safe email testing

With every send captured in a sandbox, there is zero chance of emailing real customers from dev or staging — even when staging runs on a copy of production data.

Better deliverability

Validating SPF, DKIM, and DMARC before launch means your transactional and marketing email is authenticated and lands in the inbox, protecting your sender reputation.

Improved developer workflow

Per-environment sandboxes, a developer-friendly API, and CI-ready email assertions turn email from an afterthought into a tested, reviewable part of your pipeline.

Maildog vs Mailtrap vs Mailpit / Mailhog

Mailpit and Mailhog are excellent free, self-hosted catch-all servers for a single developer's laptop, but they offer no authentication validation, no hosted sandbox, and no production sending path.

CapabilityMaildogMailtrapMailpit / Mailhog
Email sandbox (capture all mail)
Hosted (no local container to run)
Per-environment isolated inboxesLimitedManual
SPF / DKIM / DMARC validation
Developer-friendly REST APIBasic
Inbound email testingAdd-on
Transactional sending (production)
Spam / deliverability scoring
Setup time for LaravelMinutesMinutesLocal only

Frequently asked questions

What is Laravel email testing?

Laravel email testing is the practice of capturing and inspecting the emails your Laravel application sends — without delivering them to real recipients. It typically combines Mail::fake() for unit assertions with an SMTP sandbox like Maildog that captures real outbound messages so you can preview the rendered HTML, headers, and authentication results in development and staging.

How do I test emails in Laravel without sending them to real users?

Set MAIL_MAILER=smtp and point MAIL_HOST, MAIL_PORT, MAIL_USERNAME, and MAIL_PASSWORD at a Maildog sandbox in your .env file. Every email your app sends is captured in a private sandbox inbox instead of being delivered, so real users are never contacted — even if their addresses exist in your database.

What is the difference between Mail::fake() and an email sandbox?

Mail::fake() swaps Laravel's mailer for an in-memory fake so you can assert that a Mailable was queued or sent in a unit test — but it never renders or transmits anything. An email sandbox like Maildog captures the actual SMTP message, letting you see the rendered HTML, raw headers, and SPF/DKIM/DMARC results. Most teams use both: Mail::fake() in PHPUnit, and a sandbox for manual and integration testing.

How do I configure Laravel SMTP to use a sandbox?

In your .env file, set MAIL_MAILER=smtp, then set MAIL_HOST to mail.maildog.io, MAIL_PORT to the provided port (587 with STARTTLS, or 2525), and MAIL_USERNAME / MAIL_PASSWORD to your sandbox credentials. Laravel's default config/mail.php already reads these values, so no further code changes are needed.

Can I test queued Mailables and notifications with Maildog?

Yes. Mailables that implement ShouldQueue and queued notifications send through the same SMTP transport, so they land in your Maildog sandbox once a queue:work worker processes them. This confirms your queue connection, model serialization, and mail configuration are all correct end to end.

How does Maildog help with email deliverability?

Maildog validates SPF, DKIM, and DMARC for every captured message and can score messages for spam and deliverability risk. By fixing authentication and content issues in staging, you ensure your transactional email is properly signed and aligned before it reaches production, which protects your sender reputation and inbox placement.

Does Maildog work with Laravel 10 and Laravel 11?

Yes. Maildog uses standard SMTP, which Laravel 10 and 11 support out of the box through the Symfony Mailer transport. You only update environment variables — your existing Mailables, the Mail facade, and notifications work without any code changes.

Can I test inbound email and webhooks in Laravel?

Yes. Maildog's inbound email testing lets your application receive incoming messages so you can develop and test reply-by-email flows, support inboxes, and webhook parsers. You can inspect each inbound message and confirm your Laravel route or webhook handler parses it correctly.

Start Laravel email testing the safe way

Spin up a sandbox, point Laravel's SMTP at it, and capture your first Mailable in seconds.

Start testing free