A temporary email service built for Cloudflare Pages with Email Workers.
User Browser (mail.unknowns.app)
↓
Cloudflare Pages (Frontend + API Functions)
↓
Cloudflare KV (Storage)
↓
Cloudflare Email Worker (Receives inbound emails)
phantom-mail/
├── public/
│ ├── index.html # Main frontend page
│ └── app.js # Frontend JavaScript
├── functions/
│ └── api/
│ ├── generate.js # Web UI: generate temp email
│ ├── emails.js # Web UI: fetch emails for address
│ ├── qr.js # QR code generation proxy
│ ├── auth/
│ │ ├── signin.js # POST /api/auth/signin
│ │ └── signup.js # POST /api/auth/signup
│ ├── user/
│ │ ├── api-key.js # GET/POST /api/user/api-key
│ │ ├── profile.js # GET/PATCH/DELETE /api/user/profile
│ │ ├── saved-emails.js # Premium saved addresses
│ │ └── forwarding.js # Premium email forwarding
│ ├── v1/
│ │ ├── generate.js # Developer API: POST /api/v1/generate
│ │ └── emails.js # Developer API: GET /api/v1/emails
│ └── admin/
│ └── [[action]].js # Admin panel API
├── email-handler/
│ └── worker.js # Cloudflare Email Worker (deploy separately)
└── README.md
In the Cloudflare Dashboard → Workers & Pages → KV, create these four namespaces:
| Binding name | Purpose |
|---|---|
EMAILS |
Users, sessions, saved addresses, received email content, forwarding rules |
TEMP_EMAILS |
Temp email address registry (1-hour TTL) |
API_KEYS |
Developer API key lookup for /api/v1/* endpoints |
API_USAGE |
Daily rate-limit counters for developer API keys |
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/yourusername/phantom-mail.git
git push -u origin main- Go to Cloudflare Dashboard → Workers & Pages → Create → Pages
- Connect to Git → select your repository
- Build settings:
- Build command: (leave empty)
- Build output directory:
public
- Deploy
- Go to your Pages project → Settings → Functions → KV namespace bindings
- Add all four bindings created in step 1:
- Variable name
EMAILS→ select theEMAILSKV namespace - Variable name
TEMP_EMAILS→ select theTEMP_EMAILSKV namespace - Variable name
API_KEYS→ select theAPI_KEYSKV namespace - Variable name
API_USAGE→ select theAPI_USAGEKV namespace
- Variable name
- Re-deploy the Pages project after adding bindings (Settings → Deployments → Retry)
Go to Pages project → Settings → Environment variables and add:
| Variable | Required | Description |
|---|---|---|
ADMIN_SECRET |
Yes | Password for /api/admin/login. Without this, the admin panel is inaccessible. |
ℹ️ No
SENDGRID_API_KEYor any other email API key is needed. Email forwarding is handled entirely by Cloudflare's built-inmessage.forward()API in the Email Worker — it is free and requires no third-party service.
- Pages project → Custom domains → Set up a custom domain
- Add:
mail.unknowns.app - Follow Cloudflare's DNS verification steps
The email-handler/worker.js is a separate Cloudflare Worker that receives inbound emails. It must be deployed independently of Pages.
- Go to Workers & Pages → Create → Worker
- Upload / paste the contents of
email-handler/worker.js - Bind the same KV namespaces to the worker:
- Variable name
EMAILS→EMAILSKV namespace - Variable name
TEMP_EMAILS→TEMP_EMAILSKV namespace
- Variable name
- (No API keys or secrets are needed.) Forwarding uses Cloudflare's native
message.forward().
⚠️ Forwarding destination addresses must be verified in Cloudflare Email Routing.
When a premium user sets a forwarding address (e.g.their-inbox@gmail.com), that address must appear in
Email → Email Routing → Destination addresses as a verified address. Cloudflare will send a one-time
verification email — the user clicks the link, then forwarding works.
Without this,message.forward()will silently fail for unverified destinations.
This routes inbound emails for your domain to the email worker.
- Go to Cloudflare Dashboard → Email → Email Routing
- Select the domain used by your mail addresses (
unknownlll2829.qzz.ioor your own) - Under Routing rules, add a catch-all rule:
- Action: Send to a Worker
- Destination: select the email worker deployed in step 7
- Enable Email Routing for the domain if not already enabled
⚠️ Without this step, emails sent to generated addresses will never arrive.
Base URL: https://mail.unknowns.app
All /api/v1/* endpoints require the header X-API-Key: YOUR_KEY.
Get or regenerate your API key from the Premium Dashboard, or call:
# Fetch your key (also syncs it to the API_KEYS namespace)
curl https://mail.unknowns.app/api/user/api-key \
-H "Authorization: Bearer YOUR_SESSION_TOKEN"
# Generate a new key
curl -X POST https://mail.unknowns.app/api/user/api-key \
-H "Authorization: Bearer YOUR_SESSION_TOKEN"curl -X POST https://mail.unknowns.app/api/v1/generate \
-H "X-API-Key: pm_..." \
-H "Content-Type: application/json"# Replace the address below with any email generated by this service (on unknownlll2829.qzz.io)
curl "https://mail.unknowns.app/api/v1/emails?address=cool.user@unknownlll2829.qzz.io" \
-H "X-API-Key: pm_..."Rate limits: 100 requests/day (free) · 10,000 requests/day (premium)
- ✨ Instant email generation
- 📬 Real-time email checking
- 🔄 Auto-refresh every 5 seconds
- 📋 One-click copy
- ⏱️ 1-hour expiration
- 🔒 Private & secure
- 🔑 Developer API with API key authentication
- ⭐ Premium: saved permanent addresses, email forwarding, higher API limits
MIT