ShazaMail
Playwright Email Verification Testing
Use Playwright request contexts with the ShazaMail REST API so your E2E test waits for the actual verification email instead of sleeping.
Product documentation last reviewed: 2026-09-28
Create the mailbox from the same Playwright test
A robust email test owns its mailbox lifecycle. Use Playwright request.post to create a ShazaMail test inbox before filling the application signup form. Give the inbox a run_id based on the current test or CI job so later debugging can correlate the mailbox with the failing run. Keep the API key in the test environment or CI secret store rather than embedding it in source code.
Prefer event-based waiting to fixed timeouts
A hardcoded waitForTimeout introduces either flakiness or unnecessary delay because mail delivery time changes between local, CI, and provider environments. The ShazaMail wait endpoint first checks for an already-arrived message and can then wait for a delivery that matches criteria such as sender, subject, or verification-code presence. Your test resumes when the condition is met or receives a bounded timeout response.
Make failures explainable
When a verification test fails, keep the inbox ID, run ID, HTTP status, and returned request identifiers in test logs, while keeping the API secret itself out of logs. If the application sent the wrong subject or sender, query the inbox message list rather than immediately retrying the entire test. Separating application failure from mail-delivery failure makes CI triage much faster.
Primary references
Common questions
Should I use page.waitForTimeout while waiting for email?
Avoid it when possible. Waiting for a matching mail event is more deterministic and usually faster than a fixed sleep.
Where should the ShazaMail API key live?
Store it in your CI secret manager or local environment and pass it as a Bearer token. Do not commit it to the test repository.
Can multiple Playwright workers use separate inboxes?
Yes. Create one test inbox per worker or test case and include a run_id or external_reference to keep the resources attributable.