# Inbound rules

Inbound rules decide what happens to email from specific senders. Each inbound route has its own rules.

## How rules work

A rule has an action and a list of senders. A sender is an email address or a domain. A domain also matches its subdomains. Lettermint compares each sender with the address in the `From` header.

Lettermint checks the rules from top to bottom. The first rule with a matching sender decides what happens to the message. When no rule matches, the **Everyone else** setting decides.

| Action | Result |
| --- | --- |
| Allow | Lettermint delivers the message, whatever its spam score. It still quarantines a message that contains malware. |
| Quarantine | Lettermint quarantines the message, whatever its spam score. |
| Reject | Lettermint refuses the message while the sending server delivers it. The sender gets a bounce. Lettermint does not keep the message, and it does not count toward your usage. |

## Allow rules need sender authentication

An allow rule only matches a sender that passes DMARC, or DKIM or SPF for the `From` domain. If the sender fails these checks, Lettermint continues with the next rule. A forged `From` address cannot use an allow rule.

If email from an allowed sender is still quarantined, ask the sender to set up DKIM and DMARC.

Anyone can get an address at a public mailbox provider. If you allow a domain such as `gmail.com`, you allow all its users. Allow single addresses at these domains instead.

## Everyone else

**Everyone else** decides about email that no rule matches.

| Setting | Result |
| --- | --- |
| Deliver | Lettermint delivers the message. |
| Check for spam | The [spam threshold](/platform/inbound-mail/spam-filtering) of the route decides. |
| Quarantine | Lettermint quarantines the message. Only senders that an allow rule matches get through. |
| Reject | Lettermint rejects the message. Only senders that an allow rule matches get through. |

Use **Quarantine** while you build up your allow rules: you can still release a message that you did not expect. A rejected message cannot be recovered.

## Add a rule

1. Open the inbound route and select **Settings**.
2. Under **Inbound rules**, select **Add rule**.
3. Enter one sender address or domain per line, and select **Continue**.
4. Select what should happen to their email, and select **Add rule**.

Drag a rule, or use **Move up** and **Move down** in its menu, to change its position. A route can have up to 50 rules and 1,000 senders. A sender can be in only one rule per action. A change applies to the next message.

## Allow a sender from quarantine

Open a quarantined message and select **Always allow sender**. Select the address or its domain. Lettermint adds the sender to an allow rule above the rules that match it, and releases the message. An allowed domain stays below quarantine and reject rules for other addresses at that domain. If such a rule comes after a rule that matches the sender, allow the address instead.

You cannot allow a sender from a message that [contains malware](/platform/inbound-mail/malware-scanning). An allow rule does not skip the malware check.

## Examples

Accept email only from known senders:

| Position | Action | Senders |
| --- | --- | --- |
| 1 | Allow | `partner.example`, `keys@deluxe.example` |
| | Everyone else | Quarantine |

Reject a domain, but quarantine one address at it:

| Position | Action | Senders |
| --- | --- | --- |
| 1 | Quarantine | `ceo@spam.example` |
| 2 | Reject | `spam.example` |

Quarantine a domain, but allow one address at it:

| Position | Action | Senders |
| --- | --- | --- |
| 1 | Allow | `keys@deluxe.example` |
| 2 | Quarantine | `deluxe.example` |

## Webhooks and API

The webhook of a message that an allow rule let through contains `inbound_rule`. See the [`message.inbound` reference](/platform/webhooks/events#messageinbound). A rejected message sends [`inbound.rejected`](/platform/webhooks/events#inboundrejected) with the reason `sender_blocked`.

If Lettermint cannot check an allow rule while the message arrives, for example because the spam scan fails, it accepts the message and checks the rules again after the scan. If a reject rule still decides, Lettermint quarantines the message instead of rejecting it.

You can also manage rules with the Team API (`/v1/routes/{routeId}/inbound-rules`) and the MCP server. The `inbound_unmatched_action` field of the route sets **Everyone else**.
