The four pieces of the pipeline
An inbound message on Flowmails touches four Cloudflare primitives in order: Email Routing, a Worker, an R2 bucket, and a D1 database. Each one has a narrow job; the whole pipeline is short enough to read in a sitting.
- Email Routing accepts the SMTP connection for your zone and decides which Worker should receive the message.
- The Worker runs the routing logic: header parsing, address resolution, rule evaluation, attachment handling.
- R2 stores any attachments, keyed by message ID, with a short signed-URL expiry.
- D1 persists the message body, headers, routing decision, and any custom metadata your service attached.