Receive email and route it to your application
Parse messages, download attachments, and route inbound traffic via API and webhooks.
Last updated April 2026
How It Works
- Receive: Email arrives at an alias on your verified domain (e.g.,
support@mail.yourcompany.com). - Parse: BaviMail extracts the sender, recipients, subject, plain text, HTML body, headers, and attachments.
- Store: The parsed message is stored and available via the API.
- Notify: If you have a webhook subscribed to
INBOUND_RECEIVED, BaviMail sends a POST to your endpoint.
Reading Messages via API
import { BaviMail } from 'bavimail'
const client = new BaviMail()
// List inbound messages for an alias
const messages = await client.inbound.list({ aliasId: 'alias_abc123' })
for (const msg of messages.data) {
console.log(`From: ${msg.from}`)
console.log(`Subject: ${msg.subject}`)
console.log(`Body: ${msg.textBody}`)
}
// Get a single message with full details
const message = await client.inbound.get('msg_xyz789')
console.log('HTML:', message.htmlBody)
console.log('Attachments:', message.attachments.length)Features
- Parsed content: Plain text and HTML bodies extracted automatically.
- Attachments: Files are stored and accessible via download URL. Metadata includes filename, content type, and size.
- Headers: Full email headers preserved for debugging and routing.
- Conversations: Messages are threaded by
In-Reply-ToandReferencesheaders for conversation tracking.
Webhook Processing
Subscribe to the INBOUND_RECEIVED event to process messages in real time:
{
"id": "evt_abc123",
"type": "INBOUND_RECEIVED",
"createdAt": "2026-04-11T14:30:00Z",
"data": {
"messageId": "msg_xyz789",
"aliasId": "alias_abc123",
"from": "sender@example.com",
"to": "support@mail.yourcompany.com",
"subject": "Help with my account",
"textBody": "Hi, I need help resetting my password...",
"htmlBody": "<p>Hi, I need help resetting my password...</p>",
"attachments": [],
"receivedAt": "2026-04-11T14:30:00Z"
}
}See the Webhooks guide for signature verification and retry behavior.