Most email APIs today are powerful—but also over-engineered.
Across many existing solutions, a common pattern appears:
Redis for queues
Background workers
Complex retry systems
Multiple services just to send a single email
This works well at scale—but can be heavy and complex for startups and small teams.
So the question becomes:
Can a simple, scalable email API be built using just MongoDB?
That’s the idea behind Risu Mail.
🚨 The Problem with Existing Email APIs
Developers using platforms like SendGrid or Mailgun often face:
Difficulty in self-hosting
Increasing costs at scale
Limited control over data
Complex customization workflows
And when building an in-house solution, it often turns into:
“Add Redis… add queues… add workers… add retry systems…”
At that point, the focus shifts from building features to managing infrastructure.
💡 The Approach: Simplicity First
Instead of adding more components, the system is designed by removing unnecessary ones.
Core idea:
Use MongoDB as the central layer for:
Email storage
Queue handling
Status tracking
Retry logic
No Redis. No external queue system.
🏗️ Architecture Overview
- Email Creation
When a request is received:
Email data is stored in MongoDB
Status is set to pending
{
to: "user@example.com",
subject: "Welcome!",
status: "pending",
attempts: 0,
createdAt: new Date()
}
- Worker Process (Polling-based)
Instead of queues, a worker process runs at intervals:
const emails = await db.emails.find({
status: "pending"
}).limit(10);
Then:
Emails are sent
Status is updated → sent or failed
- Retry Logic
If sending fails:
if (email.attempts < 3) {
// retry later
} else {
// mark as failed
}
Simple and predictable behavior without external dependencies.
- Scaling
Scaling remains straightforward:
Multiple workers can run in parallel
MongoDB manages concurrency
Indexing ensures performance
⚙️ Features
Risu Mail is designed beyond just sending emails:
✅ Transactional emails (OTP, alerts, notifications)
✅ Campaign support (bulk emails)
✅ Template system
✅ Email logs & tracking
✅ Simple REST API
🧠 Key Insights
- Redis is not always required
For many use cases, MongoDB can effectively handle queue-like behavior.
- Simplicity improves speed
Less infrastructure leads to faster development and easier maintenance.
- Developers want control
Self-hosting is increasingly important for:
Privacy
Cost efficiency
Flexibility
⚖️ Trade-offs
This architecture is not designed for every scenario.
Limitations:
Polling is less efficient than dedicated queues
Not optimized for extremely high-scale workloads
Requires proper indexing and monitoring
Best suited for:
Startups
Indie developers
MVPs
🚀 About Risu Mail
Risu Mail — Open-source transactional email API with campaigns, OTP, and templates.risu mail
Built for:
Teams that want full control
Developers who prefer self-hosted solutions
Products that need a simpler email infrastructure
🔥 What’s Next
Upcoming improvements include:
Web dashboard
Advanced analytics
Plugin ecosystem
🙌 Feedback
Feedback and discussions are always welcome:
Would this approach work for your use case?
What features would you expect from a self-hosted email API?
What challenges exist in your current email setup?
Let’s build better developer tools together 🚀
Top comments (0)