Skip to content

Email Pipeline

MoMail processes emails through a sophisticated pipeline that ensures reliable delivery, vector indexing, and real-time notifications.

graph LR
A[Incoming Email] --> B[Email Worker]
B --> C[Queue Handler]
C --> D[Database Storage]
C --> E[Vector Embedding]
C --> F[Webhook Notification]

When an email is sent to your domain:

  1. The sender’s mail server looks up your domain’s MX records
  2. MX records point to mx.momail.io
  3. The Email Worker receives the incoming message via SMTP

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

Email data is stored across multiple tables:

TablePurpose
emailsCore email content and metadata
email_threadsConversation thread information
email_attachmentsAttachment metadata and storage references
mailboxesMailbox configuration and status

For AI-powered search, MoMail creates vector embeddings:

  1. The email body text is extracted and cleaned
  2. Text is split into chunks (typically 512 tokens)
  3. Each chunk is converted to a vector embedding
  4. 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”

If you have configured webhooks, MoMail will:

  1. Build a webhook payload with email metadata
  2. Sign the payload with your webhook secret
  3. POST to your configured URL
  4. Retry on failure (up to 3 attempts with exponential backoff)

MoMail maintains different retention policies based on your plan:

PlanEmail RetentionVector Retention
Free30 days30 days
Pro1 year1 year
EnterpriseUnlimitedUnlimited

After the retention period:

  • Email content is permanently deleted
  • Vector embeddings are removed from search
  • Thread metadata is retained for reference
  • 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

You can monitor your email pipeline through:

  1. Dashboard: Real-time statistics and recent emails
  2. Webhooks: Receive events for pipeline stages
  3. API: Query email status and delivery information
Terminal window
# Check recent emails
curl https://api.momail.io/v1/search \
-H "X-API-Key: your_key" \
-X POST \
-d '{"query": "*", "limit": 10}'