Email Pipeline
MoMail processes emails through a sophisticated pipeline that ensures reliable delivery, vector indexing, and real-time notifications.
Pipeline Overview
Section titled “Pipeline Overview”graph LR A[Incoming Email] --> B[Email Worker] B --> C[Queue Handler] C --> D[Database Storage] C --> E[Vector Embedding] C --> F[Webhook Notification]Step-by-Step Flow
Section titled “Step-by-Step Flow”1. Email Reception
Section titled “1. Email Reception”When an email is sent to your domain:
- The sender’s mail server looks up your domain’s MX records
- MX records point to
mx.momail.io - The Email Worker receives the incoming message via SMTP
2. Initial Processing
Section titled “2. Initial Processing”The Email Worker performs several tasks:
- Parsing: Extracts headers, body, and attachments
- Validation: Verifies the sender and checks for spam
- Threading: Groups related emails into conversation threads
- Metadata Extraction: Extracts sender, recipients, subject, dates
3. Database Storage
Section titled “3. Database Storage”Email data is stored across multiple tables:
| Table | Purpose |
|---|---|
emails | Core email content and metadata |
email_threads | Conversation thread information |
email_attachments | Attachment metadata and storage references |
mailboxes | Mailbox configuration and status |
4. Vector Embedding
Section titled “4. Vector Embedding”For AI-powered search, MoMail creates vector embeddings:
- The email body text is extracted and cleaned
- Text is split into chunks (typically 512 tokens)
- Each chunk is converted to a vector embedding
- Vectors are stored in Cloudflare Vectorize for similarity search
This enables semantic search queries like:
- “Emails about the Q4 budget from Sarah”
- “Find messages regarding the project delay”
- “Show me invoices from last month”
5. Webhook Notifications
Section titled “5. Webhook Notifications”If you have configured webhooks, MoMail will:
- Build a webhook payload with email metadata
- Sign the payload with your webhook secret
- POST to your configured URL
- Retry on failure (up to 3 attempts with exponential backoff)
Data Retention
Section titled “Data Retention”MoMail maintains different retention policies based on your plan:
| Plan | Email Retention | Vector Retention |
|---|---|---|
| Free | 30 days | 30 days |
| Pro | 1 year | 1 year |
| Enterprise | Unlimited | Unlimited |
After the retention period:
- Email content is permanently deleted
- Vector embeddings are removed from search
- Thread metadata is retained for reference
Privacy and Security
Section titled “Privacy and Security”- All data is encrypted at rest using AES-256
- TLS 1.3 is required for all connections
- Access is scoped to your account via API keys
- Regular security audits and penetration testing
Monitoring the Pipeline
Section titled “Monitoring the Pipeline”You can monitor your email pipeline through:
- Dashboard: Real-time statistics and recent emails
- Webhooks: Receive events for pipeline stages
- API: Query email status and delivery information
# Check recent emailscurl https://api.momail.io/v1/search \ -H "X-API-Key: your_key" \ -X POST \ -d '{"query": "*", "limit": 10}'