# Test mode

> How Test mode works, what "Test against recent mail" shows, why rules that send mail start in Test, and how to switch a rule to Live safely.

Source: https://docs.posternmail.app/rules/test-mode/

Test mode lets you watch a rule on real new mail before it changes anything. This page explains
the two ways to try a rule (Test mode and **Test against recent mail**) and how to move a rule to
Live.

| | Test mode | Test against recent mail |
|---|---|---|
| Where | **Mode** switch in the rule editor | Panel on the right of the rule editor |
| Which mail | New mail, from now on, for as long as the rule stays in Test | The newest 50 messages you already have in the rule's mailboxes |
| Result | Entries in **Rule activity** with the outcome **Simulated** | A count and a list in the editor, right away |
| Changes anything | No | No |
| Writes to the activity log | Yes | No |

## Test mode

Every rule has a **Mode**: **Live** or **Test**. Under the switch the editor explains it:

- **Live**: "Steps run on new mail."
- **Test**: "Nothing is changed or sent. Each step is written to the activity log as simulated."

A rule in Test mode is checked against every new message like a live rule. When it matches, each
of its steps is written to **Settings → Rule activity** with the outcome **Simulated** and the
same summary a live step would have, for example "Redirect to helpdesk@example.com". Nothing
happens to the message: no move, no tag, no mail sent, no web address called. The rule list
shows a **Test** label next to the rule, and its match counter ("matched 3 times") counts in Test
mode too.

A rule in Test mode never stops later rules. **Skip the rules below this one** only takes effect
in Live, and the editor says "While the rule is in Test, the rules below still run."

### Rules that send mail start in Test

A rule with **Redirect**, **Forward** or **Reply automatically** is put in Test mode when you
create it, unless you picked a mode yourself. The editor says "This rule sends mail, so it starts
in Test. Check the activity log for a few days, then switch it to Live."

The same happens when you add the first sending step to an existing live rule: the editor
switches the rule to Test, unless you set the mode by hand. The Hub enforces this as well: a
rule created without a mode, or changed to contain its first sending step without a mode, is
stored in Test.

If you switch a sending rule to Live, the editor warns "This rule sends mail as soon as you save
it."

### What a simulated entry does not tell you

A simulated step shows what the rule **would** do. Some checks happen only when a step really
runs, so a step that shows **Simulated** in Test can still be skipped or fail in Live:

- the [loop guards](https://docs.posternmail.app/rules/limits/#loop-guards) (mail sent by a rule, automatic mail, bounces),
- the checks of **Reply automatically** (newsletters, no-reply addresses, once a day per sender),
- the [daily limits and the burst pause](https://docs.posternmail.app/rules/limits/),
- errors from your provider (a refused recipient, a mailbox that needs you to sign in).

If a live rule above this one takes the message away (redirect, capture, delete), the test rule's
entries show **Skipped** with "The message was already removed by another rule", as they would in
Live.

## Test against recent mail

The panel on the right of the rule editor runs the rule against your recent mail while you edit
it. It updates a moment after each change.

- It takes the newest 50 messages in the mailboxes the rule watches.
- It shows how many match: "4 of your last 50 messages match. Nothing was changed."
- Under the count it lists the matching messages with sender, date, subject and what the rule
  would do to each. **Show all 50 messages** adds the ones that do not match (marked **No
  match**); **Show only matches** goes back.
- A step that the rule could not run shows **skipped** with the reason.

Nothing is changed, sent or logged. The panel also works for a rule in Live mode.

### Messages in the panel

| Message | Meaning |
|---|---|
| Add a condition to see which of your recent messages it catches. Nothing is changed. | The rule has no condition and no search yet. |
| Checking your recent mail… | The test is running. |
| 2 messages need their text to decide, which didn't load in time. | The rule needs the message text (see [Conditions](https://docs.posternmail.app/rules/conditions/#conditions-that-need-the-message-text)). The Hub fetches bodies for up to 15 seconds. Messages it could not fetch in time show **Can't tell yet**. |
| Fix the marked field to see what the rule catches. | The Hub refused a value, for example an invalid pattern. The field is marked in red. |
| The test didn't run. Try again. | Another error, for example the Hub was unreachable. |
| 12 conversations match. | A rule that uses only a search and no conditions. The count is of conversations, from the search. |

Steps you have not filled in yet are left out of the test until they are complete.

## Switch a rule to Live

Do this once the activity log shows that the rule catches the right mail and nothing else.

1. Open **Settings → Rule activity**, choose the rule in the rule filter and look at the
   **Simulated** entries of the last days. Check every sender and subject: would you really
   want the step to run on this message?
2. Look for mail the rule should have caught but did not. Search for it and compare it with the
   conditions in **Test against recent mail**.
3. For a redirect or forward, check the target address once more, letter by letter.
4. Open the rule in **Settings → Rules**, set **Mode** to **Live** and choose **Save**.

> **Check:** the next matching message produces entries with the outcome **Done** in **Rule
> activity**. For a sending rule, the message appears in **Settings → Sending queue** as
> **Sent**, and the recipient receives it.

> **If it did not work:** an entry with **Skipped** or **Failed** gives the reason in its detail
> line. See [Limits and guards](https://docs.posternmail.app/rules/limits/) for skipped sends and the
> [Sending queue](https://docs.posternmail.app/rules/sending-queue/) for mail that waits. To go back, set **Mode** to **Test**
> again: this takes effect for the next message.

> [!TIP]
> To try a sending rule end to end without risk, create a second rule like it that watches only
> a test mailbox and redirects or forwards to an address of your own in another mailbox.
