Build working API for programmatic email:
POST /v1/inboxes→ Create inbox instantlyPOST /v1/inboxes/{id}/send→ Send emailGET /v1/inboxes/{id}/messages→ List received- Webhooks for incoming email
Hybrid approach:
- Receiving: Mailgun routes → Webhook → Our API
- Sending: AWS SES API
- Storage: PostgreSQL (metadata) + S3 (raw emails)
- IMAP: Custom lightweight (reads from DB)
- FastAPI (Python)
- PostgreSQL + SQLAlchemy
- Pydantic models
- Docker + docker-compose
- AWS SDK (boto3)
- FastAPI app structure
- Docker setup
- PostgreSQL connection
- Basic health endpoint
- Inbox model (id, email_address, api_key, created_at)
- Message model (id, inbox_id, sender, recipient, subject, body, received_at)
- Migrations
- POST /v1/inboxes
- Generate unique email address
- Return API key for inbox
- GET /v1/inboxes/{id}
- POST /v1/inboxes/{id}/send
- Use AWS SES to send
- Store sent message in DB
- POST /v1/webhooks/mailgun
- Parse incoming email
- Store in DB
- Trigger user webhook if configured
- GET /v1/inboxes/{id}/messages
- Pagination
- Filter by read/unread
- pytest setup
- Test inboxes creation
- Test send/receive flow
# Create inbox
curl -X POST http://localhost:8000/v1/inboxes
# Send email
curl -X POST http://localhost:8000/v1/inboxes/{id}/send \
-H "Authorization: Bearer {api_key}" \
-d '{"to": "test@example.com", "subject": "Hello", "body": "World"}'
# List messages
curl http://localhost:8000/v1/inboxes/{id}/messages \
-H "Authorization: Bearer {api_key}"