\n

ShazaMail

Automated OTP Email Testing for CI/CD

Test email-based one-time codes with a repeatable inbox lifecycle and explicit assertions instead of scraping a personal mailbox.

Product documentation last reviewed: 2026-09-28

Treat the inbox as a test fixture

Create a fresh test inbox for the authentication scenario, submit that address to the system under test, and keep the returned inbox ID with the test run metadata. This prevents OTP messages from previous tests from being mistaken for the current code. Use received_after or a run-specific inbox when concurrent pipelines may generate similar messages.

Wait for a message that actually contains a verification code

The ShazaMail wait matcher supports has_verification_code so the test can ask for a delivery that already contains an extracted code. When a matching message is returned, the structured response exposes verification_code and verification_type fields. The extraction path is intended to reduce brittle HTML scraping, while the original message remains available for assertions when the surrounding text also matters.

Design assertions for real OTP failure modes

A complete test should cover more than a successful six-digit code. Useful cases include a missing message, late delivery, expired code, wrong recipient, repeated resend, multiple codes in the same message, and reuse of an already-consumed code. ShazaMail only observes and extracts the mail content; validity, expiry, one-time use, and account security rules remain the responsibility of the application being tested.

Keep verification data out of long-lived logs

OTP values are security-sensitive even in test environments. Prefer short-lived CI output, mask secret-bearing logs where possible, and avoid copying complete message bodies into permanent build artifacts unless the test environment is specifically designed for that retention. Use the inbox and message IDs for diagnosis instead of logging every credential-like value.

Common questions

Does ShazaMail decide whether an OTP is valid?

No. ShazaMail can extract the code from an email, but only the application under test can decide whether that code is valid, expired, already used, or associated with the correct user.

What if an email contains several numbers?

The extraction logic uses deterministic context and message structure, but tests should still verify that the returned code produces the expected application behavior.

Can I wait only for messages received after the test started?

Yes. The wait matcher supports received_after, which helps prevent a stale message from satisfying a new test.