Rule sets and rules - Amazon Simple Email Service
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

Rule sets and rules

After a traffic policy accepts an email, the ingress endpoint passes the email to its assigned rule set. A rule set is a reusable group of ordered rules that controls how Mail Manager processes accepted email. You can assign the same rule set to multiple ingress endpoints.

Each rule can select email or individual recipients with conditions, skip its actions when an Unless condition matches, and run one or more actions. Use rules to route email, retain a compliance copy, isolate suspicious email, invoke an application, or change an email before delivery.

How rule sets process email

The following diagram shows how a rule evaluates conditions and Unless conditions, runs ordered actions, and continues to the next rule.

Accepted email enters a rule set. Rule 1 checks all its conditions and then its Unless conditions. If all conditions match and no Unless condition matches, the rule adds an X-Route header and relays the selected recipients. A condition that does not match or an Unless condition that matches skips the actions for those recipients. Processing then continues with Rule 2, named Invoices.

Rules run in the order that you configure. Each rule uses the following flow:

  1. The rule starts with the email's current recipients.

  2. Each condition narrows the selected recipients. A recipient remains selected only if all conditions match.

  3. Each Unless condition checks the selected recipients. If any Unless condition matches a recipient, the actions do not run for that recipient.

  4. The actions run in configured order for the recipients that remain selected. The next rule then evaluates the current recipient list.

Example: Route email by recipient

This example shows how conditions select recipients and an Unless condition removes a recipient from that selection.

  • Email recipients – orders@example.com and test@example.com.

  • Conditions – Recipient ENDS_WITH @example.com.

  • Unless conditions – Recipient EQUALS test@example.com.

  • Actions

    1. Add the header X-Route: orders.

    2. Relay the email.

  • Result – The actions apply to orders@example.com. The Unless condition prevents them from applying to test@example.com.

Conditions select the recipients for a rule. Unless conditions remove recipients from that selection. The actions run only for the recipients that remain.

Choose a rule-set pattern

The following table maps common email-processing goals to rule-set patterns.

Goal Rule-set pattern
Keep a compliance copy and deliver email Archive and deliver email – Archive, then relay or send.
Isolate suspicious email Isolate suspicious email – Match a security result, write to Amazon S3, then drop.
Process application email Process email with Lambda – Match a recipient or subject, then invoke a Lambda function.
Route departments separately Route email by department – Match a department recipient, then relay.
Mark email for downstream processing Add routing information – Add a header before delivery.
Change a destination during migration Replace recipients during migration – Replace the recipient before later actions.
Related resource

For an end-to-end routing and archiving walkthrough, see AWS Messaging Blog: Mail Manager – Amazon SES introduces new email routing and archiving features.

Reference for rule conditions and actions

  • For information about selecting email and recipients with Conditions and Unless conditions, see Rule conditions.

  • For information about action order, configuration, permissions, and failure behavior, see Rule actions.