[READ-ONLY] Mirror of https://github.com/elouangrimm/mail. A simple and minimal temp email generator
README.md

Temp Mail #

Free disposable temporary email — no signup, no tracking, auto-deletes in 24 hours.

Features #

  • Instant random email address generation (word combos like swift-fox-42)
  • Custom address claiming with character/spam filter
  • Single public domain: @t.e5g.dev
  • Auto-refreshing inbox via polling (every 5s)
  • Full email viewer with HTML and plaintext toggle
  • Image attachment previews
  • Toast notifications for new emails
  • One-click address copy
  • Delete individual or all emails
  • 24-hour auto-expiry via KV TTL
  • Receive-only — no outgoing email

How it works #

Sender → Cloudflare Email Routing → Cloudflare Worker → KV Store
Browser → Vercel (static site) → Cloudflare Worker (API) → KV Store
Component Hosted on
Frontend Vercel (static HTML/CSS/JS)
API + Email Single Cloudflare Worker
Storage Cloudflare KV (24h TTL)

The frontend lives on Vercel. A single Cloudflare Worker handles both incoming emails (via Email Routing) and the REST API the frontend talks to. Emails are stored in Cloudflare KV with a 24-hour TTL.


Complete setup guide (step by step) #

Prerequisites #

You need:

  • A Cloudflare account (free) — sign up
  • A Vercel account (free) — sign up
  • Node.js installed (v18+) — download
  • The t.e5g.dev subdomain on Cloudflare
  • Git installed

Step 1 — Install the Wrangler CLI #

Open a terminal and run:

npm install -g wrangler

Then log in to your Cloudflare account:

wrangler login

This opens a browser window. Click Allow to authorize.

Step 2 — Create a KV namespace #

KV is where emails get stored. Run:

wrangler kv namespace create EMAILS

You'll see output like:

🌀 Creating namespace with title "mail-api-EMAILS"
✨ Success!
Add the following to your configuration file in your kv_namespaces array:
{ binding = "EMAILS", id = "abc123def456..." }

Copy that id value (the long string like abc123def456...).

Step 3 — Configure the Worker #

Open the file email-worker/wrangler.toml and replace YOUR_KV_NAMESPACE_ID with the id you copied in Step 2.

The file should look like this after editing:

name = "mail-api"
main = "src/index.js"
compatibility_date = "2025-01-01"

[[kv_namespaces]]
binding = "EMAILS"
id = "abc123def456..."         # ← your actual ID here

[[routes]]
pattern = "mail-api.e5g.dev/*"
zone_name = "e5g.dev"

Step 4 — Deploy the Worker #

cd email-worker
npm install
npx wrangler deploy

You should see output confirming the worker is deployed. It will be reachable at mail-api.e5g.dev.

Note: The [[routes]] block in wrangler.toml automatically routes mail-api.e5g.dev to this worker through Cloudflare. You need a DNS record for this — see Step 5.

Step 5 — Add the Worker DNS record #

In the Cloudflare dashboard:

  1. Select the e5g.dev zone
  2. Go to DNS → Records
  3. Add a new record:
    • Type: AAAA
    • Name: mail-api
    • IPv6 Address: 100::
    • Proxy: ON (orange cloud)
    • TTL: Auto

This is a dummy record — Cloudflare will route traffic to your Worker, not to that IP.

Step 6 — Configure Email Routing for t.e5g.dev #

In the Cloudflare dashboard, select the zone that covers t.e5g.dev.

If t.e5g.dev is its own zone:

  1. Go to Email → Email Routing
  2. Click Enable Email Routing if prompted (adds MX/TXT records automatically)
  3. Go to Routing Rules → Catch-all address → Edit
  4. Set action to Send to a Worker, select mail-api, click Save

If t.e5g.dev is a subdomain under the e5g.dev zone:

  1. In the e5g.dev zone, go to Email → Email Routing → Routing Rules
  2. Add a custom rule: match *@t.e5g.dev → action Send to Worker → select mail-api

Important: Cloudflare Email Routing requires MX records. The setup wizard adds these automatically. If emails aren't arriving, verify the MX records exist under DNS for the domain.

Step 7 — Update the API URL in the frontend #

Open script.js and find this line near the top:

const API_BASE = "https://mail-api.e5g.dev";

Make sure it matches the domain you configured in Step 5. If you used a different subdomain, change it here.

Step 8 — Deploy the frontend to Vercel #

Option A: Via the Vercel dashboard (easiest) #

  1. Push this repo to GitHub
  2. Go to vercel.com/new
  3. Click Import next to your repository
  4. Configure:
    • Framework Preset: Other
    • Root Directory: . (leave default)
    • Build Command: leave empty (none needed)
    • Output Directory: .
  5. Click Deploy

Option B: Via the Vercel CLI #

npm install -g vercel
vercel login
vercel --prod

When prompted:

  • Set up and deploy? → Yes
  • Link to existing project? → No (create new)
  • Project name? → tempmail (or whatever you like)
  • Directory? → .
  • Override settings? → No

Step 9 — Set your custom domain on Vercel (optional) #

If you want the frontend at something like mail.e5g.dev:

  1. In the Vercel dashboard, go to your project → Settings → Domains
  2. Add mail.e5g.dev
  3. Vercel will tell you to add a CNAME record. Go to Cloudflare DNS for e5g.dev:
    • Type: CNAME
    • Name: mail
    • Target: cname.vercel-dns.com
    • Proxy: OFF (gray cloud — Vercel needs its own TLS)

File structure #

mail/
├── index.html              ← Frontend UI
├── style.css               ← Elouan design system styles
├── script.js               ← Client logic (polling, inbox, etc.)
├── package.json            ← Root scripts
├── README.md               ← This file
└── email-worker/           ← Cloudflare Worker (API + Email handler)
    ├── src/index.js         ← Worker code (fetch + email handlers)
    ├── package.json         ← Worker dependencies (postal-mime)
    └── wrangler.toml        ← Worker config (KV, routes, passphrase)

Troubleshooting #

Emails aren't arriving:

  • Check that Email Routing is enabled and the catch-all rule points to mail-api
  • Verify MX records exist for the domain (Cloudflare adds them during Email Routing setup)
  • Check the Worker logs: Cloudflare dashboard → Workers → mail-api → Logs

CORS errors in browser console:

  • The Worker already sends CORS headers. Make sure API_BASE in script.js points to the correct Worker URL

KV namespace not found:

  • Make sure the id in email-worker/wrangler.toml matches the one from wrangler kv namespace create EMAILS
  • Redeploy the worker after changing the toml: cd email-worker && npx wrangler deploy

Tech Stack #

  • Plain HTML5
  • CSS3 (custom properties, no preprocessor)
  • Vanilla JavaScript (ES6+)
  • Cloudflare Workers + KV + Email Routing
  • Vercel (static hosting)

Design System #

This project uses Elouan's Design System.

License #

MIT