DEV Community

Cover image for Building a 100% Serverless Disposable Email Platform with Cloudflare D1 & Next.js 15
SK RAYHAN
SK RAYHAN

Posted on

Building a 100% Serverless Disposable Email Platform with Cloudflare D1 & Next.js 15

Hey DEV Community! 👋

As developers, we've all been there: you're testing a signup flow, but you don't want to clutter your personal inbox, and existing disposable email services are either too slow, full of annoying ads, or charge a premium for basic API access.

I decided to solve this by building TTMAIL (trytempmail.co) — a modern, privacy-focused, and incredibly fast temporary email platform built entirely on the edge.

🛠 The Problem I Wanted to Solve

Most "Temp Mail" services use outdated PHP/MySQL stacks or heavy polling, leading to:

  1. High Latency: Waiting 30s+ for a verification email.
  2. Privacy Concerns: Logged data and trackers.
  3. No Developer DX: Hard to use in Playwright or Cypress tests without paying.

⚡ The Tech Stack (Serverless Excellence)

I wanted zero maintenance and zero server bills. Here is how I achieved it:

🏗 Architecture Diagram


mermaid
graph LR
    Sender[Email Sender] --> CF_MX[Cloudflare MX]
    CF_MX --> Worker[Email Worker]
    Worker --> D1[(Cloudflare D1 Edge SQLite)]
    Client[Browser/CI Tool] --> API[Next.js API]
    API --> D1
🌟 Key Features for Power Users
1. ⚡ Sub-Second Speed
Because the database (D1) and the logic (Workers) live at the edge, emails are parsed and stored almost instantly.
2. 🛡️ Privacy by Design (Zero Tracking)
Pixel Stripper: Our edge worker automatically neutralizes 1x1 tracking pixels.
Auto-Purge: Emails are automatically deleted every 90 days.
3. 🤖 First-Class API for E2E Testing
Fetch emails programmatically in your CI/CD pipeline:
code
JavaScript
const response = await fetch('https://trytempmail.co/api/emails?address=qa-bot@trytempmail.co');
const { emails } = await response.json();
console.log(emails[0].subject);
4. 🔑 Cross-Device Sync
Use a custom passphrase for any alias to restore your inbox on any device.
🚀 Check it out!
Live Project: https://trytempmail.co
API Docs: https://trytempmail.co/api-docs
💬 I'd Love Your Feedback!
UI/UX: What do you think of the Neo-Brutalist aesthetic?
Features: Would you find Webhook support useful?
Performance: How is the delivery speed in your region?
Drop a comment below! 👇
Enter fullscreen mode Exit fullscreen mode

Top comments (0)