Email Testing
letsrunit generates a deterministic email address per test scenario and polls a mailbox service until the email arrives.
Typical scenario
Feature: Registration
Scenario: User activates account via email
Given I'm on page "/register"
When I set field "Email" to "user@inbox.testmail.app"
And I set field "Password" to "secret123"
And I click button "Create account"
Then The page contains text "Check your inbox"
When I open the latest email
And I click the link in the email
Then The page contains text "Account activated"
Mailbox services
Mailpit is the recommended option. It runs as a lightweight SMTP server that captures all outgoing mail, and works the same way locally and in CI.
docker run -d -p 8025:8025 -p 1025:1025 axllent/mailpit
Environment variables
MAILBOX_SERVICE=mailpit
MAILPIT_BASE_URL=http://localhost:8025 # default
Configure your app to send mail via localhost:1025 (Mailpit's SMTP port). In CI this is the same configuration. The service container listens on the same port.
info
The MAILBOX_SERVICE variable selects the backend. If it's not set, the mailbox steps will fail with a configuration error.