Separate mailboxes
Mailpit stores all received mail in a single database, but when SMTP authentication is enabled it records the authenticated username on every message. Each distinct username then appears as its own mailbox in the web UI, allowing several services to share one Mailpit instance while viewing each one’s mail separately.
This requires no additional configuration beyond enabling SMTP authentication — the mailbox switcher appears automatically once authenticated mail has been received.
Setup
1. Enable SMTP authentication with a username per service
Configure SMTP authentication using a password file, giving each service its own username, for example:
service-a:$2y$...bcrypt-hash...
service-b:$2y$...bcrypt-hash...
Start Mailpit with the credentials:
mailpit --smtp-auth-file ./smtp-auth.txt
Enabling SMTP authentication means
all senders must authenticate — unauthenticated mail is rejected. For testing over an unencrypted connection you can add the
--smtp-auth-allow-insecure flag. See
Adding SMTP authentication for the full details.
2. Point each service at its own username
Configure each application to authenticate with its own credentials, for example:
MAIL_HOST=<mailpit-host>
MAIL_PORT=1025
MAIL_USERNAME=service-a
MAIL_PASSWORD=<service-a password>
3. Switch between mailboxes
Once each service has sent mail, use the Mailbox dropdown in the web UI sidebar to switch between All mail and each username. Selecting a mailbox shows only the messages sent by that authenticated user.
The selected mailbox acts as a persistent scope: tags and searches apply within the current mailbox rather than across all mail. You can also filter directly using the username: search filter (e.g. username:service-a), or open a mailbox by URL at /mailbox/service-a.
Trusted vs. untrusted usernames
When authentication is configured with a password file, the supplied password is verified against the stored hash, so the mailbox label reflects a sender that proved it owns those credentials.
--smtp-auth-accept-anyMP_SMTP_AUTH_ACCEPT_ANYfalse
Accept any SMTP username and password (or none). Any username is accepted without a password check, so mail is filed under whatever username the sender claims, but the mailbox label cannot be trusted. Mail sent with no authentication at all has no username and only appears under All mail.
Relation to username tagging
This feature is independent of username auto-tagging (--tags-username). The mailbox switcher reads the authenticated username stored on each message directly, so you do not need to enable --tags-username to use it. Enable username tagging as well only if you also want each message labelled with a clickable username tag.
Edit this page