Browse the docs
Concepts
Shield rules
Filter inbound email with Shield rules: allow, block or reroute messages by sender, subject, body or attachments before they're stored or delivered.
A Shield rule is checked against every inbound message as it arrives, before anything else happens to it. Rules let you ignore mail you never wanted, and stop it from using up storage and deliveries.
Each rule is a set of conditions and one action:
{
"name": "Drop flagged spam",
"action": "block",
"conditions": [
{ "field": "spam_verdict", "operator": "equals", "value": "FAIL" }
]
}How rules are evaluated#
Every condition must match
The conditions in a rule are combined with AND. There's no OR and no nesting, so for "either this or that", write two rules. The limit is deliberate: when the result can be deleted mail, a filter needs to be easy to predict.
The first matching rule wins
Rules run in order, from the top. The first rule whose conditions all match decides what happens, and no later rule runs.
That makes a rule's position the most important thing about it, and also the easiest to overlook. That's why the console shows each rule's position at the start of its row.
Actions#
Deliver the message normally and stop checking. Place it above a broad block rule to make an exception to it.
Drop the message permanently. It isn't stored or delivered, but it still counts as received.
Deliver to the endpoints you name instead of the address's own.
Block deletes the message#
A blocked message is never stored. There's no quarantine folder, no body to look at later and nothing to restore. Only a record of the sender, recipient and subject is kept.
This is intentional: mail you've asked to discard shouldn't cost you storage, retention or delivery attempts. If you want to keep the message, use a route rule with no endpoints instead. That quarantines it: it stays readable over the API and MCP but isn't delivered anywhere. It's also the safe way to test a new rule before letting it delete anything.
Blocked mail still counts toward your allotment#
By the time a rule runs, the message has already been accepted, parsed and counted as a received email, so it's metered like any message you keep.
Blocking saves everything that comes after that point: storage, the retention period, delivery attempts and the clutter in your inbox. It can't undo the fact that the message arrived.
On the Free plan, mail stops being stored once you reach your allotment. A flood of junk mail uses up the allotment whether or not a rule blocks it: a block rule keeps junk out of your inbox, but not out of your quota.
Route replaces destinations#
A route rule sends the message to its own endpoints instead of wherever the
address would have sent it. "Send receipts to the billing webhook" means
instead of the usual destination, not in addition to it. Each rule can route to
at most one webhook.
Scope#
By default a rule applies to the whole account. Set domainId to limit it to
one domain, or addressId to limit it to a single address. You can't set both.
Narrowing a rule only limits which mail it checks. It doesn't change where
unchecked mail goes, and it doesn't make a narrower rule take priority over a
broader one; only position does that. An account-wide allow placed above a
domain-wide block wins, which is usually what you want.
Fields and operators#
| Field | What it checks | Operators |
|---|---|---|
from | The From header and the bare address inside it | contains, not_contains, equals, ends_with |
from_domain | The domain part of the sender's address | equals, ends_with, contains |
to | The recipient being checked (see below) | equals, contains, starts_with |
subject | The subject line | contains, not_contains, equals, starts_with, ends_with |
body | The text and HTML bodies together, first 256 KB | contains, not_contains |
has_attachment | Whether there are any attachments | is_true, is_false |
attachment_name | Any attachment's filename | contains, ends_with, equals |
attachment_type | Any attachment's content type | equals, contains, starts_with |
spam_verdict | Amazon SES's spam result (PASS, FAIL or GRAY) | equals |
spf_verdict | The SPF result | equals |
dkim_verdict | The DKIM result | equals |
All comparisons ignore case. The attachment fields match if any attachment
matches, with one exception: not_contains must be true for every attachment,
so a rule for "no .exe attachment" isn't satisfied just because one other
file is harmless.
There's no regular-expression operator, on purpose. A pattern you write would
run against text that a stranger chose, on every message, which is an easy
way to slow the system down. contains covers what filters need in practice.
One message to several recipients#
A single message can be addressed to several of your addresses. Rules are checked for each recipient separately, and the results are combined:
- If a block applies to every recipient, the message is dropped.
- If it applies to only some, the message is still stored for the others, and the blocked recipients don't get a delivery.
A rule for one recipient can never delete another recipient's mail.
Reviewing blocked mail#
Because a blocked message isn't kept, each block records its envelope instead:
sender, recipient, subject, the rule that caught it, and when. You can read
these in the console under Shield, in Recently blocked, or over MCP with
list_shield_blocks.
The records expire on the same retention schedule as stored mail. They're kept even after the rule that produced them is deleted, so you can still see what a removed rule was catching.
Where Shield runs#
Virus check
Mail that Amazon SES flags as containing a virus is dropped before any rule runs.
Shield rules
Rules run here. A blocked message is dropped and counted: it never reaches storage or delivery, but it counts as received.
Quota
Every plan stops receiving once its monthly allotment is used. Paid plans can turn on pay-as-you-go to keep receiving and pay for the extra mail instead.
Storage and delivery
The message is stored and sent to its endpoints. If a Shield
routerule matched, its endpoints replace the address's own.
Limits#
| Plan | Rules |
|---|---|
| Free | 3 |
| Basic | 10 |
| Pro | 50 |
| Scale | Unlimited |
Shield is on every plan, with a limit on the number of rules rather than a paid upgrade. Filtering is what keeps an inbox usable, and charging extra for it would put it out of reach of exactly the accounts with the most junk mail. The limit only bounds how much matching work each message can cause.