1. Docs
  2. Reference
  3. Step reference
  4. Mail steps

Mail steps

Sign-up, password reset and two-factor login send emails. The mail steps read those emails from a test mailbox so the test can go on: type the code, open the link, or check that a message arrived.

4 min read Updated CustomersAdmins

In short

On this page you can

  • Read a verification code from a new email with Extract OTP.
  • Read a confirmation or reset link with Extract Link.
  • Wait until an email arrives and save its subject and content with Wait for Mail.
  • Count emails with Get Mails and send one with Send Mail.
  • Filter by sender, subject or content, with your own timeout.

How to use it

  1. Have an admin connect the test mailbox on the Integrations page.
  2. Click More › Mail; fill Test Step Name and pick the Email Integration.
  3. Choose the Operation Type and fill Sender Filter.
  4. Name the Output Variable, for example otp.
  5. Add a Type step with {{tc:otp}} right after it, then save and run.

The five mail operations#

Operation TypeChipDoesRequiredOutput
Extract OTPExtract OTPExtract verification code (OTP) from emailSender Filter, Output VariableThe code
Extract LinkExtract LinkExtract verification/reset link from emailSender Filter, Output VariableThe link
Wait for MailWait MailWait for a specific email to arriveSender FilterSubject and content, if named
Get MailsGet MessagesGet emails from inboxSender FilterNone (the count is logged)
Send MailSend MailSend emailRecipientNone

Mail steps exist in web, mobile and desktop projects.

Add a mail step#

  1. Check the mailbox connection

    Mail steps read and send through an email integration (an IMAP and SMTP account) set up on the Integrations page. Without one, the dialog says “Email integration has not been configured yet. Please configure email from the Integrations page first.”

  2. Open the dialog

    Click More › Mail. The dialog Add Email Step opens.

  3. General Information

    Fill Test Step Name (for example Get OTP code) and pick the Email Integration. Choose the Operation Type.

  4. Parameters

    Fill the fields of the operation (below). Required fields are marked. Values can contain variables, for example a Subject Filter of Code for {{tc:userEmail}}.

  5. Add and use the output

    Click Add. In a later step use the output: Type {{tc:otp}} into the code field.

Add Email Step dialog with Operation Type Extract OTP, Sender Filter, OTP Pattern, Timeout 60 and Output Variable otp
The Add Email Step dialog for Extract OTP.

Fields#

FieldUsed byDefaultMeaning
Sender FilterAll but Send Mail—Text to search in the sender address, for example noreply@example.com. Required.
Subject FilterAll but Send Mail—Text to search in the subject, for example Verification code.
Content FilterWait for Mail—Text to search in the content.
OTP Pattern (Regex)Extract OTP\b(\d{6})\bThe code to find. The default is a 6-digit number. For a 4-digit code use \b(\d{4})\b.
Link ContentExtract Link—Text the link must contain, for example /verify.
Timeout (seconds)Extract OTP, Extract Link, Wait for Mail60Maximum waiting time, 1–600.
Output VariableExtract OTP, Extract Link—Variable to store the result, for example otp. Required.
Subject Output, Content OutputWait for Mail—Variables to store the email’s subject and content. Optional.
Unread OnlyGet Mailstruetrue or false.
Max Mail CountGet Mails10Maximum number of emails to retrieve, 1–100.
Recipient, CCSend Mail—Addresses. Recipient is required.
Subject, ContentSend Mail—Variables allowed: Test Report - {{tc:date}}.
HTML FormatSend Mailfalsetrue sends the content as HTML.

Output names in one step must differ: “Output variables must be unique”.

Which emails a step sees#

Extract OTP, Extract Link and Wait for Mail look only for new mail in the inbox: unread messages that arrived after the step started (with a 30-second margin for mail that arrived just before). Unread mail that was already there is ignored, so an old code from an earlier run is never used. The step checks the mailbox every 5 seconds until a message matches or the timeout ends.

Mail windowExtract OTP, Extract Link, Wait for Mail
a message matches when:  unread  AND  received ≥ (step start − 30 s)  AND  filters match
the step gives up at:    step start + Timeout (seconds)

Example: the step starts at 10:00:00 with Timeout 60. A matching mail received at 09:59:45 counts (within 30 s); one received at 09:59:00 does not. If none arrives by 10:01:00, the step ends with “Timeout: No email with OTP found within 60 seconds”.

Extract OTP#

Finds the newest matching email and takes the first text that matches OTP Pattern (Regex). The code is saved in the output variable and the email is marked as read, so the next run cannot pick it up again.

Example · two-factor login
4  Click         Send code
5  Extract OTP   Sender Filter: security@shop.example.com   Output Variable: otp
6  Type          Code field   value: {{tc:otp}}
7  Click         Verify

Finds the newest matching email and takes the first http:// or https:// link that contains Link Content. Follow it with a Navigate step: value {{tc:link}}.

Wait for Mail#

Waits until a matching email arrives. Optionally saves its subject and content into Subject Output and Content Output, which you can check with an Assertion (for example the content Contains Order 1042).

Get Mails#

Reads up to Max Mail Count emails that match the filters and logs how many it found (“Found 3 emails”). It does not wait and produces no variable.

Send Mail#

Sends an email through the integration’s SMTP account, for example to trigger a mail-in workflow of your app or to send a short result. Log: “Email sent to: …”.

Outputs and results#

  • Outputs are saved as {{tc:name}}: {{tc:otp}}, {{tc:link}}, {{tc:mailSubject}}.
  • Any error (timeout, mailbox connection, sending) ends the step as ERROR and stops the test case.
  • The mailbox is reached from the machine that runs the test.

If something goes wrong#

Didn’t find your answer?Write to support with your project name and what you see on screen.

info@smartestqa.ai
© 2026 Selenity Technology · SmartestQAsmartestqa.aiThis page as MarkdownChecked against smarttest-fe predev 2a8c79cc, smarttest-be 633c2a03, smarttest-testsuite 017fcec