Skip to content

Email Sending Pipeline

When a user sends an email, the system separates the act of submitting the email from the act of delivering it. This keeps the JMAP API responsive and ensures delivery is retried reliably even if something fails after the user’s request completes.


graph LR
Client["JMAP client"]
API["JMAP API<br/>EmailSubmission/set"]
SQS["SQS Queue<br/>email-submissions"]
DLQ["SQS DLQ<br/>(14 day retention)"]
Lambda["Lambda<br/>email-sender"]
SES["Amazon SES"]
Internet["Recipient's<br/>mail server"]
Client -->|"POST /jmap"| API
API -->|"enqueue"| SQS
SQS -->|"max 5 retries"| DLQ
SQS --> Lambda
Lambda --> SES
SES --> Internet

The JMAP API creates the submission record, enqueues it to SQS, and returns immediately. The email-sender Lambda processes the queue independently.


A client sends an email by calling EmailSubmission/set with a create operation. This requires two things to already exist:

  • An Email object in the Drafts mailbox (the MIME content, stored in S3)
  • An Identity — the verified sending address to use as the From

Before creating the submission record, the API checks the suppression list synchronously for every envelope recipient. A recipient is blocked by a hard-bounce suppression that has not expired, or by a complaint suppression for the message’s class; soft bounces never block. If any recipient is blocked, EmailSubmission/set rejects the call in the same response with a SetError of type invalidRecipients that lists the blocked addresses, and records the attempt in the audit trail. No submission record is created, nothing is enqueued, and no request reaches SES. If the lookup for a recipient fails, the submission is refused rather than sent: an unchecked recipient is never sent to. This happens entirely inside the JMAP API; the email-sender Lambda below never sees a suppressed recipient.

Otherwise, the API creates a submission record that links the two, then enqueues it for sending. Each recipient starts as queued (see Submission lifecycle).

The client can also provide:

  • An envelope override to control the SMTP MAIL FROM and RCPT TO addresses independently of the message headers

sendAt is set by the server to the time the submission was created; a create that supplies sendAt is refused with invalidProperties.

Every submission created through JMAP is handled as transactional mail; clients do not choose a message class.


graph TD
A["Submission arrives from SQS"]
B["Fetch MIME from S3"]
C["Validate identity &<br/>resolve envelope"]
D["Apply user signature<br/>(server-side)"]
E["Tag the message<br/>(SES tags)"]
F["Send via SES"]
G["Move Drafts → Sent"]
H["Mark submission as sent"]
A --> B --> C --> D --> E --> F --> G --> H

The message body is not stored in the SQS message — only the submission record is. The Lambda looks up the Email record to find its S3 key and downloads the content. This keeps queue messages small.

If the user has a signature configured on the sending identity, it is injected into the MIME at send time — not at compose time. This means the draft in the user’s Drafts folder stays clean (no signature), and the outgoing message gets the current signature regardless of when the draft was written.

Text and HTML parts are each updated independently. For HTML, the signature is inserted before </body> if present, or appended at the end.

Before calling SES, the Lambda attaches metadata tags to the message:

TagPurpose
tenant_idRoutes feedback events back to the correct tenant
submission_idLinks bounce/complaint/delivery events to this submission
identity_idTracks which sending identity was used
account_id / user_idFor audit and suppression records
domainThe sending domain, for reputation analytics
message_classScopes suppression list entries correctly

These tags travel with the message through SES and appear on every feedback event (bounce, complaint, delivery). Without them, the system would not know which submission a bounce refers to.

The full message is handed off to SES for delivery. This is what activates the feedback event pipeline — every bounce, complaint, and delivery notification flows back through the feedback pipeline.

Immediately after a successful SES call, the Lambda moves the email from the Drafts mailbox to the Sent mailbox and removes the $draft keyword. This is best-effort — if it fails, the email was still sent, and the failure is logged rather than propagated.


Not all SES errors are equal:

Error typeExamplesAction
RetryableThrottling, rate limits, 5xx server errorsReturn error — SQS retries up to 5 times, then DLQ
PermanentInvalid parameters, identity not verified, no envelopeMark submission as failed; no retry

Permanent failures write no as the delivery status of each recipient back to the submission record so the sender can see what went wrong. The email remains in Drafts.


A client reads the state of a send from the EmailSubmission. Its undoStatus is final for every send: the server offers no scheduled send and no cancelation.

Each recipient the client can see has a deliveryStatus entry, and its delivered value moves like this:

graph LR
queued --> unknown
queued --> no
unknown --> yes
unknown --> no
deliveredMeaning
queuedThe submission is created and waits to be sent
unknownSES accepted the message and has not yet reported an outcome, or reported a delay or a temporary failure
yesSES reported the message delivered to the recipient’s server
noThe send failed permanently, SES rejected it, or the recipient bounced or reported a complaint

The change from unknown to yes or no happens asynchronously via the SES feedback pipeline. displayed is always unknown.

smtpReply has the form 250 2.0.0 text: a reply code, an enhanced status code and a text.

The EmailSubmission/set create answer carries the generated envelope and the initial deliveryStatus (every recipient queued), so a client shows the state without a further EmailSubmission/get.

There is no suppressed state here: a suppressed recipient is rejected synchronously by EmailSubmission/set before a submission record exists, so it never enters this lifecycle at all (see Step 1 above).