# Steps

> Every rule step, what it does on Gmail, Microsoft, IMAP and JMAP, its fields and limits, which steps can be combined, and the risks of the steps that send or remove mail.

Source: https://docs.posternmail.app/rules/steps/

Steps are what a rule does with a message that matches. This page lists every step in the
**Then** menu of the rule editor, what it does at your mail provider and what to watch out for.

## How steps work together

- Steps run in the order shown in the editor, with one exception: the step that takes the
  message out of its folder runs last, wherever it is in the list.
- A rule can have **only one** step that takes the message away: **Redirect**, **Capture**,
  **Delete**, or a move (**Archive**, **Move to folder**, **Move to Spam**, and **Move to Trash**
  in older rules). The menu marks such a step **Only one** once the rule has one. If you try to
  save two, the Hub refuses: "A rule can contain only one of Redirect, Capture, Delete or a move
  (Archive, Trash, Spam, Move to folder)".
- **Mark as read** and **Mark as unread** cannot be in the same rule, nor can **Star** and
  **Remove star**. The menu shows **Conflicts** next to the other one.
- **Tag**, **Copy to folder**, **Forward** and **Call a web address** can be added several
  times. Every other step once.
- A rule can have up to 10 of the newer steps (everything except Archive, Move to folder, Move to
  Spam, Move to Trash, Mark as read, Star, Tag, Inbox tab and Notify me). Within that, the
  editor allows 20 rows in all.
- Steps that are not filled in yet (an empty address, no folder picked) are left out of
  **Test against recent mail** until you fill them in.

### Which steps run where

All steps run on the Hub. When the Hub has been unreachable for more than two minutes, a desktop
or mobile app runs the rules itself, but only these steps: **Archive**, **Move to folder**,
**Move to Spam**, **Move to Trash**, **Delete** to Trash, **Mark as read**, **Mark as unread**,
**Star**, **Remove star**, **Tag**, **Inbox tab** and **Notify me**. The others (Redirect,
Forward, Reply automatically, Capture, Copy to folder, Delete for good, Call a web address, Send a
notification) run only on the Hub, which handles the message when it is back.

### Steps on mail you already have

**Save and apply to mail I already have** runs only Tag, Mark as read, Star, Archive, Move to
folder, Move to Spam and Move to Trash. See
[Apply a rule to mail you already have](https://docs.posternmail.app/rules/).

## The step menu

| Group | Step | Hint in the menu | Sends mail | Removes the message |
|---|---|---|---|---|
| Move or remove | [Archive](https://docs.posternmail.app/rules/steps/#archive) | Skip the Inbox. | | Out of the Inbox |
| | [Move to folder](https://docs.posternmail.app/rules/steps/#move-to-folder) | | | Out of its folder |
| | [Copy to folder](https://docs.posternmail.app/rules/steps/#copy-to-folder) | | | |
| | [Move to Spam](https://docs.posternmail.app/rules/steps/#move-to-spam) | | | Out of its folder |
| | [Delete](https://docs.posternmail.app/rules/steps/#delete) | Move to Trash, or delete for good. | | To Trash, or for good |
| | [Capture](https://docs.posternmail.app/rules/steps/#capture) | Keep a copy on your Hub and take it out of the mailbox. | | For good (copy on the Hub) |
| Mark | [Mark as read](https://docs.posternmail.app/rules/steps/#mark-as-read-and-mark-as-unread) | | | |
| | [Mark as unread](https://docs.posternmail.app/rules/steps/#mark-as-read-and-mark-as-unread) | | | |
| | [Star](https://docs.posternmail.app/rules/steps/#star-and-remove-star) | | | |
| | [Remove star](https://docs.posternmail.app/rules/steps/#star-and-remove-star) | | | |
| | [Tag](https://docs.posternmail.app/rules/steps/#tag) | | | |
| | [Inbox tab](https://docs.posternmail.app/rules/steps/#inbox-tab) | Put it in an Inbox tab. | | |
| Tell me or another service | [Notify me](https://docs.posternmail.app/rules/steps/#notify-me) | Always or never notify for this mail. | | |
| | [Send a notification](https://docs.posternmail.app/rules/steps/#send-a-notification) | A notification with your own text. | | |
| | [Call a web address](https://docs.posternmail.app/rules/steps/#call-a-web-address) | Tell another service that mail arrived. | | |
| Send mail | [Redirect](https://docs.posternmail.app/rules/steps/#redirect) | Send it on unchanged, then take it out of the mailbox. | Yes | For good (copy on the Hub) |
| | [Forward](https://docs.posternmail.app/rules/steps/#forward) | Send a copy to someone else. | Yes | |
| | [Reply automatically](https://docs.posternmail.app/rules/steps/#reply-automatically) | Answer the sender with a fixed text. | Yes | |

The steps under **Send mail** carry a **Sends mail** label in the editor. A new rule with one of
them starts in [Test mode](https://docs.posternmail.app/rules/test-mode/).

## Move or remove

### Archive

Takes the message out of the Inbox.

| Provider | What happens |
|---|---|
| Gmail | The **Inbox** label is removed. The message stays in **All Mail** and under its other labels. |
| Microsoft | The message is moved to the **Archive** folder. |
| IMAP | The message is moved to the archive folder. If the server marks none, a folder named `Archive` is used. On Gmail over IMAP, the Inbox label is removed. |
| JMAP | The message is put in the archive mailbox (created as `Archive` if there is none) and taken out of the Inbox. |

### Move to folder

Moves the message to a folder you pick. The picker shows your own folders and the archive folder
of the mailboxes the rule watches. A folder belongs to one mailbox. For a message in another
mailbox the move fails with "Moving mail to a folder of a different mailbox isn't supported yet.
Pick a folder in the mailbox the conversation belongs to." So for a move, limit the rule to the
folder's mailbox under **In mailboxes**, and make one rule per mailbox if you need more.

| Provider | What happens |
|---|---|
| Gmail | The folder is a label: the label is added and the **Inbox** label (or the label the message came from) is removed. |
| Microsoft, IMAP | The message is moved to the folder. |
| JMAP | The message is moved to the mailbox. |

### Copy to folder

Puts a copy of the message in another folder and leaves the original where it is. You can add
this step several times. Runs only on the Hub.

| Provider | What happens |
|---|---|
| Gmail | The folder's label is added. Gmail keeps one message with two labels, not two copies. |
| JMAP | The message is added to the second mailbox. JMAP keeps one message in two mailboxes. |
| Microsoft, IMAP | A copy is uploaded to the folder with the same read and star state and the same date. These are two separate messages from then on. |

A failed copy appears in the [sending queue](https://docs.posternmail.app/rules/sending-queue/) with **Cancel copy**. The
activity log has no **Undo** for a copy.

### Move to Spam

Moves the message to the spam folder.

| Provider | What happens |
|---|---|
| Gmail | The **Spam** label is added; **Inbox** and **Trash** are removed. |
| Microsoft | The message is moved to **Junk Email**. |
| IMAP | The message gets the `$Junk` keyword where the server allows it and is moved to the junk folder (`Junk` if the server marks none). |
| JMAP | The message is moved to the junk mailbox and gets the `$junk` keyword. |

### Delete

Without options, moves the message to Trash. With **Delete for good instead of moving to Trash**
ticked, the message is deleted permanently at the provider.

**To Trash**: Gmail adds the **Trash** label; Microsoft moves to **Deleted Items**; IMAP moves to
the trash folder (`Trash` if the server marks none); JMAP moves to the trash mailbox. Your
provider empties Trash on its own schedule (Gmail after 30 days).

**For good**: the editor shows "Your Hub keeps a copy for {n} days, so you can still get it
back." The Hub first stores an encrypted copy of the message, reads it back and checks it, and
only then deletes the message at the provider. You find the copy in
[Captured mail](https://docs.posternmail.app/rules/captured-mail/) under **Deleted for good** until it expires (30 days by
default, see [Limits and storage](https://docs.posternmail.app/rules/limits/#limits-and-storage-settings)). Runs only on the Hub.

| Provider | How "for good" deletes |
|---|---|
| Gmail | Permanent delete through the Gmail API. The message does not go to Trash. |
| Microsoft | Permanent delete through Microsoft Graph. It does not go to **Deleted Items**. |
| IMAP | The message is flagged deleted and expunged. On Gmail over IMAP it is first moved to Trash, then expunged there, because Gmail would otherwise only remove a label. |
| JMAP | The message is destroyed. |

> [!WARNING]
> After the Hub's copy has expired, a message deleted for good cannot be recovered by Postern.
> Whether your provider can still restore it depends on the provider.

### Capture

Keeps the message on your Hub and takes it out of the mailbox. Use it for mail you want to keep
but not have in your mail account, for example to stay under a storage quota. Runs only on the
Hub.

The Hub stores an encrypted copy, checks it, then deletes the message at the provider in the
same permanent way as **Delete for good**. Unlike a deleted message, a captured message is kept
until you delete it yourself under [Captured mail](https://docs.posternmail.app/rules/captured-mail/). The activity log shows
"Capture (keep on the Hub)".

> [!NOTE]
> A captured message is gone from all your apps and from the provider's web mail. It exists
> only on your Hub. Include the Hub's data in your [backups](https://docs.posternmail.app/admin/backups/).

## Mark

### Mark as read and Mark as unread

Set the message's read state. Gmail removes or adds the `UNREAD` label, Microsoft sets
`isRead`, IMAP sets or clears `\Seen`, JMAP sets or clears `$seen`.

### Star and Remove star

Set or clear the star. Gmail uses the **Starred** label, Microsoft the flag, IMAP `\Flagged` and
JMAP `$flagged`.

### Tag

Adds one of your [tags](https://docs.posternmail.app/using/tags/). Add the step several times for several tags. How the
tag is stored at the provider:

| Provider | Stored as |
|---|---|
| Gmail | A Gmail label with the tag's name, created when it is first needed |
| Microsoft | An Outlook category |
| IMAP | A keyword on the message, if the server allows keywords |
| JMAP | A keyword on the message |

### Inbox tab

Puts the message in one of the Inbox tabs: **People**, **Notifications** or **Newsletters**,
whatever tab Postern would have picked on its own. See [The inbox](https://docs.posternmail.app/using/inbox/). Like
**Notify me**, it is decided before your devices are told about the message.

## Tell me or another service

### Notify me

**Always** or **Never** notify for this mail. **Always** asks your devices to notify for it,
**Never** keeps it quiet. Without this step, mail that a rule archives, moves to Spam or Trash,
or takes out of the mailbox does not notify. See [Notifications](https://docs.posternmail.app/using/notifications/).

This step decides before your devices are told about the message. A rule that needed the message
text (see [Conditions](https://docs.posternmail.app/rules/conditions/#conditions-that-need-the-message-text)) is decided too late
for it, and the activity log shows it as **Skipped**.

### Send a notification

Sends a notification of its own to your devices, independent of the normal new-mail
notification. Runs only on the Hub.

| Field | Meaning |
|---|---|
| Text (placeholder "Same as for new mail") | Optional, up to 500 characters. With a text, the notification's title is your text and its body "From" and the sender's address. Empty, it looks like a new-mail notification: sender as title, the start of the message as body. |
| **Also send it to your alert channels** | Also posts to your ntfy, Discord or Gotify channel. The text there reads `Rule “Invoices”: your text`, or `Rule “Invoices”: “subject” from sender@example.com` without a text. Set the channels up under [Alerts](https://docs.posternmail.app/rules/alerts/). |

### Call a web address

Sends a JSON message to a web address you choose (a webhook). The editor says "Gets the rule
name, mailbox, sender and subject. Never the message text." Runs only on the Hub. The web
address must start with `http://` or `https://`, be at most 2,000 characters, and point to a
public address unless your admin allows local ones. See [Webhooks](https://docs.posternmail.app/rules/webhooks/) for the payload,
retries and security.

## Send mail

All three steps send from the mailbox the message arrived in, through that mailbox's provider.
They run only on the Hub, go through the [sending queue](https://docs.posternmail.app/rules/sending-queue/), count toward the
[daily limits](https://docs.posternmail.app/rules/limits/) and are checked by the [loop guards](https://docs.posternmail.app/rules/limits/#loop-guards). Every
message a rule sends carries headers that mark it as automatic: `Auto-Submitted`, plus
`X-Postern-Id` and `X-Postern-Rule`.

### Recipients

**Redirect** and **Forward** take one to five addresses, separated by commas. Addresses are
stored in lower case. Saving is refused if one of them is an address of the mailbox itself
(its address or one of its aliases), because the message would come back and match the rule
again. The comparison ignores case, `+tag` parts, dots in Gmail addresses and treats
`googlemail.com` as `gmail.com`. The error reads, for example: "steps.0.to: you@example.com is
this mailbox's own address, so the message would come back and match again".

### Redirect

Sends the message on unchanged, then takes it out of the mailbox. Use it to hand mail over to
another address, for example a shared support inbox.

| Field | Meaning |
|---|---|
| **Redirect to** | One to five addresses |
| **Put before the subject** | A text placed before the subject, `[REDIR]` by default, up to 50 characters. Empty (placeholder "Nothing") leaves the subject as it is. Not added twice if the subject already starts with it. |

What the recipient gets:

- **From** is your mailbox's address (its default sender), because providers do not let you
  send in someone else's name. **Reply-To** is the original Reply-To or, without one, the
  original sender, so a reply goes to the original sender.
- **To** is the redirect address. The original Cc and Bcc are not sent along.
- The message body and attachments are byte for byte the original. The original `Date` is kept.
- Headers tied to the original delivery are dropped: `Received`, DKIM and ARC signatures,
  `Authentication-Results`, `Return-Path`, `Delivered-To`, `Resent-*` and similar.
  `X-Postern-Original-Message-Id` holds the original Message-ID.

The order of events: the Hub stores an encrypted copy and checks it, deletes the message at the
provider (permanently, as with **Delete for good**), then sends. After the send it removes the
copy of the redirect that the provider put in your Sent folder, so your Sent folder does not fill
up with redirects. The Hub's copy stays in [Captured mail](https://docs.posternmail.app/rules/captured-mail/) under
**Redirected** for 30 days by default.

> [!WARNING]
> A redirect removes the message from your mailbox. If the target address is wrong, the message
> is still on your Hub: use **Restore to mailbox** in the sending queue or **Undo** in the
> activity log. A redirect that was already delivered cannot be called back.

### Forward

Sends a copy of the message to other addresses. The original stays in your mailbox.

| Field | Meaning |
|---|---|
| **Forward to** | One to five addresses |
| **Note above the forwarded message (optional)** | Up to 5,000 characters, placed above the forwarded message |
| **Forward as an attachment** | Attach the original as an `.eml` file instead of quoting it |
| **Keep a copy in Sent** | On by default. Off, the Hub removes the forward from your Sent folder after sending. |

A normal forward has the subject `Fwd: ` plus the original subject (unless it already starts with
`Fwd:` or `FW:`), your note, a "---------- Forwarded message ---------" block with From, Date,
Subject, To and Cc, the original text and HTML, and the original attachments. As an attachment,
the text is your note or "Forwarded message attached." and the original is attached whole.

### Reply automatically

Answers the sender with a fixed text, for example while you are away.

| Field | Meaning |
|---|---|
| **Reply text** | The reply, 1 to 10,000 characters, plain text. No signature is added. |
| **Keep a copy in Sent** | On by default. Off, the Hub removes the reply from your Sent folder after sending. |

The editor says "Sent at most once a day to each sender, and never to newsletters or no-reply
addresses." In detail, no reply is sent:

| Activity detail | When |
|---|---|
| No automatic reply to mail sent from this mailbox | The message came from your own mailbox |
| The message has no sender to reply to | No From or Reply-To address |
| No automatic reply to automated mail or mailing lists | `Auto-Submitted` other than `no`, any `List-*` header, `Precedence: bulk`, `list` or `junk`, or `X-Auto-Response-Suppress` asking for no replies |
| No automatic reply to a no-reply address | Addresses such as `noreply@`, `no-reply@`, `do-not-reply@`, `mailer-daemon@`, `postmaster@`, `bounce@`, `listserv@`, `majordomo@`, `owner-...@`, `...-request@`, `...-bounces@` |
| Loop guard: the sender is this mailbox | The reply would go to the mailbox itself |
| Already replied to sender@example.com in the last 24 hours | An automatic reply from this mailbox already went to this sender in the last 24 hours (from any rule) |
| No automatic reply to a delivery report | The full message turns out to be a bounce |

The reply goes to the original Reply-To, or the sender without one. The subject is `Re: ` plus
the original subject; `In-Reply-To` and `References` make it part of the conversation. It also
carries `Auto-Submitted: auto-replied` and `X-Auto-Response-Suppress: All`, so other
auto-responders do not answer it.

## Risks at a glance

| Step | What can go wrong | What protects you |
|---|---|---|
| Redirect | A wrong address gets your mail; the message leaves your mailbox | Test mode for new rules, own-address check, encrypted copy, **Restore to mailbox**, **Undo** |
| Forward | A wrong address gets a copy; a loop between two mailboxes | Test mode, loop guards, daily limits, burst pause |
| Reply automatically | Answering newsletters, bots or a loop with another auto-responder | No replies to automated mail and no-reply addresses, once a day per sender, loop guards |
| Delete for good, Capture | A too broad rule removes mail you wanted | Encrypted copy on the Hub, **Undo**, [Captured mail](https://docs.posternmail.app/rules/captured-mail/) |
| Call a web address | The service receives sender and subject | Only public addresses by default; no message text is sent |

Before you switch a rule that sends or removes mail to Live, run it in [Test mode](https://docs.posternmail.app/rules/test-mode/)
for a few days.
