Guides

Development mode

Accidentally emailing real customers from a laptop is the classic mistake. MailingKit makes the safe thing the default and gives you three ways to see your emails without sending them.

Nothing is sent until you say so

If MAILINGKIT_PROVIDER is not set, MailingKit uses the console provider. Every email is printed to the terminal and nothing leaves the machine:

terminal
========================================================================
MailingKit console provider: this email was NOT sent
------------------------------------------------------------------------
From:     Example App <no-reply@example.com>
To:       ada@example.com
Subject:  Welcome to Acme Cloud, Ada
------------------------------------------------------------------------
Welcome, Ada

Your Acme Cloud workspace is ready.

Open your workspace (https://app.example.com)
========================================================================

Set MAILINGKIT_CONSOLE_SHOW_HTML=true to print the HTML body too.

Preview real emails as .eml files

env
MAILINGKIT_PROVIDER=file
MAILINGKIT_FILE_DIR=.mailingkit/outbox

Each email is written as a standard .eml file. Double-click one and your mail client (Outlook, Apple Mail, Thunderbird) shows exactly what the recipient would see, with attachments and inline images. Add .mailingkit/ to your .gitignore.

A local inbox with Mailpit

For a browser inbox, run Mailpit and point the SMTP provider at it. This also exercises the real SMTP path:

bash
docker run --rm -p 8025:8025 -p 1025:1025 axllent/mailpit
env
MAILINGKIT_PROVIDER=smtp
MAILINGKIT_SMTP_HOST=localhost
MAILINGKIT_SMTP_PORT=1025
MAILINGKIT_SMTP_SECURITY=none

Then open http://localhost:8025.

Staging: redirect everything

Staging should use real delivery, but never reach real users. Set one variable and every email, from every code path, goes to one inbox instead:

env
MAILINGKIT_REDIRECT_TO=qa-team@example.com

The original to, cc and bcc recipients are removed and listed in an X-MailingKit-Original-To header so testers can still see who the email was meant for. SendResult.redirected is True for these sends.

Recommended setup

Development: no provider (console) or file. Staging: the real provider plus MAILINGKIT_REDIRECT_TO. Production: the real provider only.