Receive email and route it to your application
Parse messages, download attachments, and route inbound traffic via API and webhooks.
Last updated November 25, 2026
How It Works
-
Receive: Email arrives at an inbox address on your verified domain (e.g.,
[email protected]). Mail to an address without an active inbox is not stored. There is no catch-all. -
Parse: Bavimail extracts the sender, To and Cc recipients, Reply-To, subject, plain text and HTML bodies,
Message-ID,In-Reply-ToandReferences, a retained set of headers, SPF/DKIM/DMARC/spam/virus verdicts, and attachments. -
Store: The parsed message is stored and available via the API. This happens before any webhook is sent.
-
Notify: If you have a webhook subscribed to
email.inbound.received, Bavimail sends a POST to your endpoint.
Limits
| Limit | Value | What happens past it |
|---|---|---|
| Raw message size, attachments and encoding included | 40 MB (41,943,040 bytes), the Amazon SES receiving limit | The message is not stored. |
| Size of one attachment | 25 MB (26,214,400 bytes) | That attachment is left out and the message is stored without it. |
| Attachments per message | 50 | Attachments after the 50th are left out and the message is stored without them. |
Reading Messages via API
import { Bavimail } from 'bavimail'
const client = new Bavimail({ apiKey: process.env.BAVIMAIL_API_KEY! })
// List inbound emails for an inbox, newest first (summaries)
const page = await client.inboundEmails.list({ inboxId: '0193f6a0-1b2c-7d3e-8f40-a1b2c3d4e5f6' })
for (const msg of page.data) {
console.log(`From: ${msg.fromAddress}`)
console.log(`Subject: ${msg.subject}`)
console.log(`Attachments: ${msg.attachmentCount}`)
}
// Get a single message with bodies, headers and attachments
const message = await client.inboundEmails.get('0193f6c2-7d1e-7a40-9c55-3f2b8e1d4a10')
console.log('Text body:', message.bodyText)
console.log('Attachments:', message.attachments.map((a) => a.filename))GET /inbound-emails/{email_id} returns the full message. Attachments are not inlined. Each one carries a signed download_url and its expires_at. Fetch the message again for a fresh link after it expires.
{
"id": "0193f6c2-7d1e-7a40-9c55-3f2b8e1d4a10",
"user_id": "user_2pQxR7sT9uVwXyZ",
"inbox_id": "0193f6a0-1b2c-7d3e-8f40-a1b2c3d4e5f6",
"thread_id": "0193f6c2-7d20-7b11-a2c3-d4e5f6a7b8c9",
"inbox_address": "[email protected]",
"domain": "mail.yourcompany.com",
"from_address": "[email protected]",
"from_name": "Vendor Billing",
"subject": "Invoice 4471",
"ses_message_id": "q8c1v0mbc4o2r7d9e3f5g6h7i8j9k0l1m2n3o4p5",
"received_at": "2026-11-25T14:30:00.000Z",
"processing_error": null,
"attachment_count": 1,
"created_at": "2026-11-25T14:30:01.000Z",
"updated_at": "2026-11-25T14:30:01.000Z",
"reply_to": null,
"recipients": { "to": [{ "address": "[email protected]" }], "cc": [] },
"body_html": "<p>Invoice 4471 is attached.</p>",
"body_text": "Invoice 4471 is attached.",
"headers": [
{ "name": "From", "value": "Vendor Billing <[email protected]>" },
{ "name": "Message-ID", "value": "<[email protected]>" }
],
"message_id": "<[email protected]>",
"in_reply_to": null,
"thread_references": null,
"verdicts": { "spam": "PASS", "virus": "PASS", "spf": "PASS", "dkim": "PASS", "dmarc": "PASS" },
"attachments": [
{
"id": "0193f6c2-7d31-7e02-91a4-b5c6d7e8f901",
"filename": "invoice-4471.pdf",
"size_bytes": 184320,
"mime_type": "application/pdf",
"sha256": "9f2b5c0e4a7d1f3b6c8e0a2d4f6b8c0e2a4d6f8b0c2e4a6d8f0b2c4e6a8d0f2b",
"download_url": "https://<signed attachment URL>",
"expires_at": "2026-11-25T14:45:01.000Z",
"content_id": null,
"is_inline": false,
"position": 0
}
]
}Features
-
Parsed content: Plain text and HTML bodies extracted automatically.
body_textandbody_htmlare the message's full bodies as sent. Bavimail does not strip quoted replies or signatures, so a reply's text includes any history the sender's client quoted. -
Attachments: Files are stored and accessible via a signed download URL. Metadata includes
filename,mime_type,size_bytes,sha256,content_idandis_inline. -
Headers: A fixed set of headers is kept in message order, duplicates included:
Date,From,To,Cc,Reply-To,Sender,Return-Path,Subject,Message-ID,In-Reply-To,References,Delivered-To,Original-Recipient,MIME-Version,Content-Type,Content-Transfer-Encoding,List-ID,List-Unsubscribe,List-Unsubscribe-Post,Auto-Submitted,PrecedenceandFeedback-ID. Keep more with a domain'sextra_retained_headers(exact names, or a prefix ending in*).Bccis never kept. -
Conversations: Messages are threaded by
In-Reply-ToandReferencesheaders for conversation tracking. Threading never uses the subject. A reply to an email you sent through Bavimail joins that email's thread, andthread_idis set on every message.
Webhook Processing
Subscribe to the email.inbound.received event to process messages in real time. The event is a summary: it carries no bodies, headers or attachments. Fetch those with GET /inbound-emails/{email_id}.
{
"event_id": "0193f6c2-7d40-7f13-a2b5-c6d7e8f90a1b",
"event_type": "email.inbound.received",
"timestamp": "2026-11-25T14:30:00.000Z",
"data": {
"email_id": "0193f6c2-7d1e-7a40-9c55-3f2b8e1d4a10",
"inbox_id": "0193f6a0-1b2c-7d3e-8f40-a1b2c3d4e5f6",
"inbox_address": "[email protected]",
"domain_id": "0193f5e1-4c2a-7b90-8d1e-2f3a4b5c6d7e",
"from_email": "[email protected]",
"from_name": "Dana Kim",
"subject": "Help with my account",
"body_preview": "Hi, I need help resetting my password...",
"attachment_count": 0,
"received_at": "2026-11-25T14:30:00.000Z"
}
}body_preview is the first 100 characters of the text body, or of the HTML body when there is no text, with whitespace collapsed. from_name is null when the sender gave none. domain_id is null for mail synced from a connected mailbox.
See the Webhooks guide for signature verification and retry behavior.
What happens if my webhook endpoint is down?
You do not lose the email. The message is stored, and its email.inbound.received event is created in the same transaction, before any delivery is attempted. Webhook failures never touch the stored message.
- Bavimail retries a non-2xx response up to 6 attempts in total, waiting 5, 10, 30, 60 and 120 seconds between them. A timeout or connection error is not resent automatically.
- Whatever happened to the webhook, the message stays readable with
GET /inbound-emailsandGET /inbound-emails/{email_id}until you delete its thread. Inbound messages are not removed after a fixed time. Deleting a thread works only after it is moved to trash. The one exception is dormancy: an account on the Free plan alone that makes no authenticated API or dashboard request for 365 days becomes dormant, gets an email notice, and is deleted with everything in it 60 days later, with a reminder 7 days before; any authenticated request in those 60 days, or a paid plan, cancels the deletion. - To catch up after an outage, page through
GET /inbound-emails(newest first, up to 100 per page) and process the ids you have not seen.
One case does refuse mail: when the account's storage stays full past its grace period, new inbound mail is not stored. The sender gets an "Undeliverable" notice and you get an email.inbound.rejected event.
How does inbound email work?
Add the MX record Bavimail generates for your domain (priority 10, pointing at Amazon SES inbound in your region) and create an inbox for each address you want to receive. When email lands, Bavimail parses headers, body (plain and HTML), and attachments, stores the message, then delivers a signed email.inbound.received webhook with a summary. The full message comes from GET /inbound-emails/{email_id}, where attachments are signed URLs the agent can fetch directly — no giant inline blobs.
Verify your domain for production email delivery
Configure DNS records for SPF, DKIM, and DMARC with step-by-step guidance.
Signed webhook deliveries backed by the real event model
Bavimail emits outbound lifecycle events, inbound receipt events, domain verification events, and test pings. Verification should match the actual SDK helper and header contract.