Webhooks
Receive incoming mail and delivery events in your application or agent through signed Mailly webhooks, with retries and redelivery.
Configure a public HTTPS endpoint in Webhooks. Incoming mail supports a workspace default endpoint, and each address can have several endpoints of its own. Delivery webhooks let you choose the events you need.
Incoming mail
email.received: use the message ID andthread_idin the event to fetch the body or the full thread through the API.email.batch: sent instead ofemail.receivedwhen the endpoint merges mail (see batch window below);emailsholds oneemail.receivedemail object per message.webhook.test: click Send test to send a sample email through the endpoint exactly like a real delivery (template, headers, body length). The result shows the receiver's status code, its response body and the request body that was sent. In raw mode the payload has theemail.receivedshape plustest: true; any 2xx response passes.
Delivery settings
Every incoming endpoint (the workspace default and each address endpoint) has the same delivery settings, in the web app under Delivery settings and in the API on the endpoint object.
- Request headers: up to 10 custom headers, for example
Authorization: Bearer …or a version header the receiver requires. Values are stored encrypted and only returned masked (valueHint). To keep a stored value, send the header name withoutvalue. - Request body:
payloadMode: "raw"sends the full event.payloadMode: "template"sends your own JSON template. Variables are JSON-escaped, so put text variables inside quotes:{{from}},{{from_name}},{{to}},{{subject}},{{snippet}},{{body_markdown}},{{body_text}},{{thread_id}},{{message_id}},{{internet_message_id}},{{received_at}},{{truncated}},{{attachments_count}},{{count}},{{emails}}.{{message_id}}is the Mailly email ID, so an agent can read the full email with it through the API, CLI or MCP. - Body length:
bodyMaxChars(100–20000) cuts long bodies; templates mark a cut body with…[truncated]and{{truncated}}istrue. - Filters: only send mail from or not from certain senders (address or domain, subdomains included), with or without subject keywords, and skip automated mail (auto-replies, bulk and list mail, bounces). The default endpoint can also be limited to certain recipient addresses. Skipped mail is not queued.
- Rate limit and batching:
maxPerMinutecaps requests per minute; extra mail waits instead of being dropped.batchWindowSeconds(10–3600) waits that long and sends the mail that arrived meanwhile as one request. In templates,{{count}}is the number of emails and{{emails}}lists each sender, subject,message_idand body; other variables use the newest email. - Retries: non-2xx responses are retried with backoff (1 min, 5 min, 15 min, 1 h, …) up to
maxAttempts(1–8). Every request carries anIdempotency-Keyheader that stays the same across retries: the email ID, or the batch ID for a merged request. The delivery log shows status codes, response bodies and errors, and any delivery can be sent again.
{
"text": "New email from {{from}}\nSubject: {{subject}}\nmessage_id: {{message_id}}\n\n{{body_markdown}}"
}mailly inbox webhook set \
--url https://your-service.example.com/mailly \
--body-format markdown \
--strip-quotes --jsonThis command changes webhook configuration. Replace the URL with an HTTPS endpoint you own, and use a separate inbox for testing.
Delivery events
Delivery webhooks report recipient-level outcomes such as delivered, bounced and complained. A successful send request does not replace the final delivery status. Events can be inspected and replayed in the workspace.
Verifying requests
- Verify the
Mailly-Signatureheader on every request. - Deduplicate by event ID or
Idempotency-Key; failed deliveries are retried. - A signing secret is displayed once, after creation or rotation.