# The test inbox

> Email addresses Rehearsal makes for your tests, and how a test reads a code or a link from them.

Source: https://rehearsal.dev/docs/reagent/test-inbox

Some flows send an email, such as a sign-in link, a code or an invitation. Rehearsal gives test accounts and new users their own email addresses, so Re:agent and your tests can read that mail.

## Addresses

Test inbox addresses end in `@inbox.rehearsal.dev`. An account's address names your workspace and the account, and Rehearsal creates it with the account.

| Who uses it | Address | Example |
| --- | --- | --- |
| An account that signs in **with an email code or link** | The same address every time. | `acme-admin@inbox.rehearsal.dev` |
| A new user, in a flow that signs up | A new address for every browser Re:agent opens and every run. It starts with `fresh-`. | `fresh-55a96c3ffd89f41f2379c02b9bfed590036a9b08b973006c@inbox.rehearsal.dev` |

A password account gets an address only when its code after the password is sent by email. Rehearsal reads the code sent there. See [Test accounts and secrets](https://rehearsal.dev/docs/reagent/test-accounts.md).

## How Re:agent reads it

When the flow sends an email, Re:agent reads the newest messages for that browser's address. It can wait up to two minutes for one to arrive.

Re:agent gets each message's text, its links and any codes. Rehearsal finds codes of four to eight digits in the subject or the text. Links to your app come first.

The chat keeps only a short line, such as how many messages arrived and the newest subject. A code in the subject is left out of it.

A code Re:agent types is saved as `{{code}}`. A link it opens is saved as `{{link}}`.

## In the test

The written test reads the inbox again every time it runs. It waits for the newest message and takes a fresh code or link from it, so an old code never ends up in the test.

In a sign-up, the test calls `identity()` for the run's new address and types it into the form. Every run signs up a new user.

## See the messages

Under **Re:agent uses**, open **Test accounts** and press the arrow on an account with an address. You see the last messages it received.

A code shows only its last three digits. Press **Show** to see all of it, if you have the **Manage projects** permission.

## What to know

- Rehearsal keeps each message for seven days.
- A new user's address keeps receiving mail for 30 days.
- Mail marked as spam or as carrying a virus is dropped, and so are automatic replies.
- If your test environment sends mail only to some domains, add `inbox.rehearsal.dev` to them.

## Next steps

- Test [flows with more than one person](https://rehearsal.dev/docs/reagent/more-than-one-person.md), such as an invitation by email.
- Read [From flow to test](https://rehearsal.dev/docs/tests/from-flow-to-test.md) to see how the test is written.
