Mail guides
08 · Route incoming mail

Send each email where it belongs.

Inbound routes decide what happens to the email an address receives: keep it, forward it, push it to your app, or drop it.


1

Routes, rules and actions

A route belongs to one address on a receiving domain, like support@in.acme.com, or to the whole domain: the catch-all (local_part: "*"), which takes every address that has no route and no mailbox of its own.

A route holds up to 20 rules, checked in order. Each rule has conditions and up to 5 actions:

  • store: keep the email in the route's mailbox. With keep: false it is deleted once the other actions ran, for addresses that only forward.
  • forward: send it on to up to 10 confirmed addresses (section 3).
  • webhook: deliver the email.received event to one of your webhook endpoints, even if that endpoint does not subscribe to it.
  • drop: throw it away. Nothing is stored and no webhook goes out. It must be the only action of its rule.

Conditions all have to match: from (addresses or whole domains like @example.com), subject_contains, to_includes, has_attachments and spam. A rule without conditions matches every email. The first rule that matches runs. Set stop: false to go on to the next rule that matches as well; the actions add up, and an address is forwarded to only once.

POST /inbound-routes
curl -X POST 'https://api.mail.productcraft.co/v1/workspaces/<ws>/inbound-routes' \
  -H 'authorization: Bearer pcft_live_...' \
  -H 'content-type: application/json' \
  -H 'idempotency-key: route-support' \
  -d '{
    "domain_id": "<receiving domain id>",
    "local_part": "support",
    "rules": [
      {
        "name": "Invoices to accounting",
        "conditions": { "subject_contains": "invoice" },
        "actions": [{ "type": "store" }, { "type": "forward", "to": ["<destination id>"] }]
      },
      { "name": "Everything else", "actions": [{ "type": "store" }] }
    ]
  }'

2

Which route runs

  1. The address's own route, if it has one and is switched on.
  2. Otherwise, if the address has a mailbox or an alias, the email is stored there, as without routes.
  3. Otherwise the domain's catch-all route.
  4. Otherwise the email is refused: nobody receives at that address.

When none of an address route's rules match, the email falls through the same way: to the address's mailbox, else to the catch-all. Try a route before you rely on it: POST /inbound-routes/{id}/test with a sender, subject and spam flag tells you which rules would match and what they would do, and sends nothing.


3

Forwarding

A forwarded email is sent again from the route's own address, with the sender's name in front: "Alice Example via support@in.acme.com". Its Reply-To is the original sender, so pressing Reply in the receiving mailbox answers them directly. The subject, the text and HTML, and the attachments are kept, with a short note on top saying who sent it, to whom, when, and whether it passed SPF, DKIM and DMARC.

Why not keep the sender's own address in From? Because most of them publish a DMARC policy that tells mailbox providers to reject email claiming to come from them through anyone else's servers, so a forward that kept it would often bounce or land in spam. Sending from your address, which your domain signs, is the way mailing lists stay deliverable too. It also means the domain has to send mail as well as receive it (intent: both).

You forward only to confirmed addresses. Add one with POST /forward-destinations: a member's verified email is confirmed at once; any other address gets an email from ProductCraft with a confirmation link (valid 7 days) and a link to say they did not ask for it. Nobody receives forwards they did not agree to. Forwards count toward your sending limits, and an address on your suppression list is skipped. Over 10 MB of attachments, the forward goes out without them and links to the email in the console instead.

POST /forward-destinations
curl -X POST 'https://api.mail.productcraft.co/v1/workspaces/<ws>/forward-destinations' \
  -H 'authorization: Bearer pcft_live_...' \
  -H 'content-type: application/json' \
  -d '{ "address": "ops@example.com" }'
# → { "id": "…", "address": "ops@example.com", "status": "pending", … }

4

Spam, loops and limits

  • Spam is not forwarded. Forward and webhook actions skip email the spam filter flagged, and email that failed DMARC for a sender whose policy says quarantine or reject. It stays in the mailbox. A rule with spam: "any" forwards it anyway; spam: "spam" matches only spam.
  • No loops. A route is refused when its forward would come back to it through your own routes. At delivery, a forward is skipped when the email already went through one of your routes, has passed more than 20 servers, or comes from the route's own address.
  • Limits. Each route forwards at most 60 emails an hour and 500 a day. Over that, email is still stored, and the workspace audit log records it once an hour.

5

See what happened

Every received email shows its routing: GET /received and GET /received/{id} carry routing (each action with its status: sent, skipped, spam_held, rate_limited, loop_blocked, failed) and forwarded_at. Filter with ?forwarded=true. A forward is an ordinary sent email too: find it under GET /emails by its email_id, with the tag purpose=route_forward. Dropped email leaves no inbox entry, only a route_drop line in the rejection log. Managing routes needs the mail.route.manage permission (owners and admins); mail.route.read lets members see them.