Skip to main content

How do I test an email that my app sends?

Receive the emails that your app sends in a test, open them with an Open email step, and read them on the Test inbox page.

Written by Ines

Each Test Project has its own test inboxes. Your app sends its emails, such as a sign-up confirmation, a one-time code or a reset link, to a test address of the project. An Open email step then waits for the email and opens it in the run, and the Test inbox page shows every email that the project received in the last 7 days.

1. Find the test addresses of your project

  1. Open your Test Project.

  2. Click Configure, then Test inboxes.

The page shows:

  • Slug: the first part of every test address of the project. Only support can change the slug.

  • Inbox domains: the domains that receive the emails.

  • Example address: a ready-made address that you can copy.

A test address is the slug, a dot, a tag of your choice, and an inbox domain. For example, with the slug acme-shop, the address [email protected] uses the tag signup. A tag holds lowercase letters, digits and hyphens.

2. Give the address to your app

In the step that fills the email field of your app, type one of these:

  • [TEST_RUN_EMAIL]: a new address in each run. Use it for a sign-up, so that each run creates a new account and parallel runs never read the email of another run.

  • A fixed address, such as [email protected]: the same address in every run. Use it for an account that already exists, for example to test a password reset.

The Variable [EMAIL_PREFIX] holds the slug of the project, so [EMAIL_PREFIX][email protected] works in every project.

3. Open the email in the run

  1. In your Test Case, add a step after the step that makes your app send the email.

  2. In Step type, select Open email.

  3. In Address, choose A new address for each run to read [TEST_RUN_EMAIL], or The same address for all runs and type its tag. The step shows the address that it reads.

  4. (Optional) In Sender (optional), type the address of the sender. The step then waits only for an email from this sender.

  5. (Optional) In Wait in seconds (optional), type how long the step waits for the email, from 1 to 80 seconds. The default is 60 seconds.

  6. Click Add.

The Open email dialog with the address options, the Sender (optional) and Wait in seconds (optional) fields, and the four Variables that the step saves

When the step runs, it waits for the newest email to the address, for 60 seconds or for the wait that you set, and opens it in a new tab. The next steps act on that tab: click the link of the email, read a code, or check its content. To go back to your app, add a Web Step with the action Switch To Tab.

The step also saves four Variables that the next steps can use:

  • [EMAIL_CODE]: the first code of 4 to 8 digits.

  • [EMAIL_LINK]: the first link.

  • [EMAIL_SUBJECT]: the subject.

  • [EMAIL_TEXT]: the text of the email.

On a Mobile App, the step opens no page. It saves the same four Variables, and the next steps use them, for example to type [EMAIL_CODE] in the app.

4. Read the emails of the project

To see the emails that your tests received, click Test inbox in the menu of the project. This page is not the Test inboxes page of section 1: Test inboxes shows the addresses of the project, and Test inbox shows the emails that they received.

The Test inbox page with the list of emails on the left, and the selected email on the right with its Preview and Details tabs and the Load images and Download .eml buttons
  • The list shows the sender, the subject, the recipient and the time of each email, newest first. It updates every 10 seconds.

  • To see the emails of one address, type it in Recipient address and click Show the emails. Leave the field empty to see all the emails.

  • Click an email to open it. The Preview tab shows the email as a mail client shows it. The Details tab shows the sender, the recipient, the time, the codes, the links and the attachments.

  • The preview blocks the images that the email loads from the internet. Click Load images to show them.

  • Click Download .eml to save the email as a file that any mail client opens.

The emails stay on the page for 7 days.

FAQ

How do I give each run its own email address?
Type [TEST_RUN_EMAIL] in the email field of your app, and choose A new address for each run in the Open email step. Each run gets a new address, so runs in parallel never read the email of another run.

How do I type the one-time code of the email in my app?
Add an Open email step, then a step that types [EMAIL_CODE] in the code field of your app. [EMAIL_CODE] holds the first code of 4 to 8 digits in the email.

How do I make sure that the email comes from my app?
Type the address of your app in Sender (optional), and use a new address in each run with [TEST_RUN_EMAIL]. Anyone can send an email to a test address, and the sender of an email can be faked, so these two settings make a wrong email unlikely but not impossible.

How do I fix an Open email step that fails?
The step fails when no email reaches the address within its wait: 60 seconds, or the value of Wait in seconds (optional). When your app sends the email late, set a longer wait, up to 80 seconds. Open the Test inbox page of the project and filter on the address: when the email is not there, check that your app sent it to exactly that address.

How long do test emails stay?
7 days. After that, Thunders deletes them, and they no longer show on the Test inbox page.

Related articles on this topic that you might find helpful

Did this answer your question?