Skip to content

Rules

A rule acts on mail as it arrives. Each rule is a when / if / then sentence — when a mail arrives, if it matches your conditions, then act on it — built visually in the console under Rules. The rules engine is included on Team and up; the approval flow (the pause for review action, then approve or reject) is Business and up (Plans & add-ons). Switching a rule off stays possible on every plan.

A few real shapes:

  • If the subject contains [staging], pause the mail — a guard against test sends reaching customers.
  • If the recipient domain is gmail.com, route through Amazon SES — provider steering by audience.
  • If the message is bigger than 10 MB, reject — policy at the gateway instead of in every app.
  • If the mail is tagged invoice, BCC the bookkeeping inbox.

A rule lives at one of three levels, evaluated in this order:

Scope Applies to Managed by
Platform every team (safety rules Mailway itself sets) Mailway; read-only to you
Team every project in your team admins
Project one project admins & developers

Within a scope, rules run in the priority order you set (drag to reorder). A stop action halts the chain for that mail.

  • On receipt — the moment Mailway receives the mail. Envelope-level facts (sender, size) are available; recipient and content conditions match after parsing.
  • After parsing — once the message is parsed. Content conditions (subject, body, headers, attachments) match here.

The console picks the right trigger for the conditions you choose.

Condition Matches on
subject_contains / subject_matches subject substring / regex
body_contains / body_matches body substring / regex
from_email_is / from_domain_is exact sender / sender domain
recipient_email_in / recipient_domain_in / recipient_domain_not_in recipient allow/deny sets
recipient_count_gt more than N recipients
recipient_domain_is_typo a recipient domain that is a known mistyping of a big mailbox provider’s domain, for example gamil.com for gmail.com. Pair it with pause to hold such mail until someone releases or rejects it; Mailway doesn’t correct the address.
header_present / header_value_is a header exists / equals a value
attachment_count_gt / attachment_filename_matches attachment count / filename pattern
size_gt / size_lt message size
tag_present a tag from the send request’s tags, or one an earlier rule applied
ingest_type_is how the mail entered (SMTP, API, console)

Multiple conditions AND together.

While you build, the editor dry-runs your conditions against your own recent mail — through the same filter engine live rules use — and shows how many of the last mails would have matched, with examples. A pattern that’s too loose (or matches nothing) is visible before the rule ever fires. It previews this one rule in isolation: other rules’ tags, pauses and stops aren’t simulated, and it projects matching only — never routing or delivery.

On any mail (state and envelope only — the relayed bytes stay untouched):

Action Effect
pause hold the mail until someone releases it in the console
reject stop it permanently, with an optional reason (sent as data.rule.reason on the mail.failed webhook)
route_provider pin the send to specific provider(s)
tag / untag label the mail (searchable; listed in data.mail.tags on webhook events)
add_bcc add a blind recipient to the envelope
stop halt rule processing for this mail

On API-submitted mail only (these modify content, which would break the byte-for-byte promise on relayed SMTP messages):

Action Effect
add_cc / redirect_to add a visible recipient / replace all recipients
prepend_subject prefix the subject, e.g. [STAGING]
add_header / set_reply_to set a header / the reply-to
inject_unsubscribe add List-Unsubscribe (+ one-click) headers
generate_text_part synthesize a text/plain part from the HTML

Every rule shows its match history — which mails it touched, when, and what each action did. Rule edits are versioned and recorded in the team’s security history (shown on the Audit log page, Business and up), so “why was this mail paused?” always has an answer.