Advanced

Email Mailbox

Test email workflows like OTP codes, magic links, and password resets

When You Need It

Many app flows send emails that users must act on. If your test involves any of these, you need mailbox integration:

Use CaseWhat the test does
Email OTP / Verification CodeSign up, receive a verification email, extract the 4-8 digit code, type it in
Magic Link LoginTrigger a magic link email, extract the link, navigate to it
Password ResetRequest a password reset, extract the reset URL from the email, complete the reset
Team/User InvitationSend an invite, extract the accept link from the email, click to accept
Transactional Email VerificationTrigger a transactional email (order confirmation, receipt), verify it arrived with the right content
Email Content AssertionsAssert that an email's subject, body, or sender matches expected values
Link ExtractionExtract any action link from an email — confirm account, unsubscribe, approve request
Multi-step Email ChainsApproval workflows where multiple emails are sent in sequence
Deliverability CheckVerify that an email was sent at all within a timeout

Configuring Mailboxes

Connect one or more email inboxes in Settings → Integrations → Email Mailbox. Each mailbox has a name you'll reference in your test steps (e.g. signup-inbox, admin-inbox).

Provider Options

ProviderWhat you need
GmailYour Gmail address and an App Password (not your regular password)
OutlookYour Outlook address and an App Password
Custom IMAPIMAP host, port, username, password, and whether TLS is enabled

For Gmail users: you need to generate an App Password in your Google Account settings. This is a 16-character password specifically for third-party apps. Your regular Gmail password won't work with IMAP.

Setup Steps

  1. Go to Settings → Integrations → Email Mailbox
  2. Click Add Mailbox
  3. Give it a name (e.g. signup-inbox)
  4. Select your provider (Gmail, Outlook, or Custom IMAP)
  5. Enter your credentials
  6. Click Test Connection to verify it works
  7. Click Save

You can add multiple mailboxes — for example, one for the user signing up and another for an admin receiving notifications.

Credentials are encrypted at rest and scoped to your organization. They are never logged or included in test traces.

Email Steps

Three new step types are available in the step palette under the Email category.

Wait for Email

Polls a named mailbox for a matching email.

FieldDescription
MailboxName of the mailbox to poll (as configured in Settings)
Subject containsSubstring or regex to match the email subject
FromSender email address to filter by
TimeoutHow long to wait before failing the step (default: 60 seconds)
Save to variableVariable name to store the full email object

The step polls the specified mailbox repeatedly until it finds a matching email or the timeout is reached. When found, the full email (subject, body text, body HTML, sender, date) is stored in the specified variable for use in later steps.

If no matching email arrives within the timeout, the step fails.

Extract from Email

Extracts an OTP code, link, or text from an email stored in a variable.

FieldDescription
Email variableThe variable from a previous Wait for Email step
Extract typeWhat to extract: OTP Code, Link, or Text
PatternFor OTP: the digit count (e.g. 6). For Link/Text: a regex pattern
Save to variableVariable name to store the extracted value

Use this after a Wait for Email step. It reads the email from the variable you specify and extracts the value you need:

  • OTP Code — Finds a numeric code of the specified length (e.g. 6 digits) in the email body
  • Link — Finds a URL matching your pattern (e.g. https://app.com/verify.*)
  • Text — Extracts arbitrary text using a regex with a capture group

The extracted value is saved to a variable you can use in subsequent Type or Navigate steps.

Assert Email

Asserts that an email's content matches your expectations.

FieldDescription
Email variableThe variable from a previous Wait for Email step
Subject matchesRegex the subject should match
Body containsText the email body should contain
From matchesExpected sender email or pattern

All three fields are optional — you can assert on any combination. The step passes if all specified conditions match, and fails with details about what didn't match.

End-to-End Example

Here's a complete test for sign-up with email verification:

Step 1:  Navigate         → https://app.com/signup
Step 2:  Type             → "test@gmail.com" into email field
Step 3:  Type             → "Password123" into password field
Step 4:  Click            → "Sign Up" button
Step 5:  Wait for Email   → mailbox "signup-inbox", subject contains "Verification", save to {{verificationEmail}}
Step 6:  Extract from Email → OTP (6 digits) from {{verificationEmail}}, save to {{otpCode}}
Step 7:  Type             → {{otpCode}} into OTP input
Step 8:  Click            → "Verify" button
Step 9:  Assert AI        → "User is logged in and sees dashboard"

Steps 1-4 trigger the sign-up flow. Step 5 waits for the verification email to arrive. Step 6 pulls out the OTP code. Steps 7-8 complete the verification. Step 9 confirms success.

You can use the same pattern for magic links (extract a link instead of an OTP, then use a Navigate step) or password resets.

Tips

  • Timeouts — Set your Wait for Email timeout based on how fast your app sends emails. 30-60 seconds is a good default. Transactional email services are usually fast, but some apps batch or delay emails.
  • Subject filters — Be specific enough to avoid matching the wrong email, especially if the inbox receives other messages. Combine subject and from filters when possible.
  • Parallel test runs — If multiple test runs share the same inbox, emails are filtered by timestamp so each run only sees emails sent after the test started. No cross-contamination.
  • Gmail rate limits — Gmail allows roughly 15 concurrent IMAP connections. If you run many tests in parallel against the same Gmail inbox, you may hit this limit. Consider using separate inboxes for parallel suites.
  • Connection reuse — Within a single test run, the IMAP connection is reused across multiple email steps. You don't need to worry about connection overhead.
Email Mailbox | QAbyAI Documentation | QAbyAI Docs