Skip to content

πŸ“« An open source temporary email tool, fully on Cloudflare. Inspired by oiov/vmail

License

Notifications You must be signed in to change notification settings

MiraHikari/cloudflare-vmail

Repository files navigation

Cloudflare VMails

A modern, privacy-focused temporary email service powered entirely by Cloudflare's edge network.

License Astro Cloudflare

Inspired by oiov/vmail. This project has been completely rewritten with modern technologies and enhanced features.

✨ Features

Core Features

  • πŸ”’ Privacy First - No registration required, anonymous by default
  • πŸ“§ Email Management - Receive and view emails instantly
  • πŸ” Mailbox Claiming - Optionally claim mailboxes with password protection
  • πŸ” OTP Detection - Automatic extraction and display of verification codes
  • 🌐 Multiple Domains - Support for multiple email domain suffixes
  • 🎨 Modern UI - Beautiful interface with light/dark mode support
  • πŸ“± Responsive Design - Optimized for all screen sizes
  • ⚑ Edge Performance - Lightning fast with Cloudflare's global network

Technical Features

  • πŸš€ 100% Serverless - Runs entirely on Cloudflare (Workers + Pages + D1)
  • πŸ›‘οΈ Bot Protection - Integrated Cloudflare Turnstile
  • 🎯 Type Safety - Full TypeScript implementation
  • 🎭 Smooth Animations - Refined page transitions and interactions
  • πŸ“š Built-in Documentation - MDX-powered docs system
  • πŸ”§ Easy Deployment - One-command deployment to Cloudflare

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Cloudflare Edge                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Email Worker │───▢│  Cloudflare  │◀───│ Astro Pages  β”‚ β”‚
β”‚  β”‚ (Receives)   β”‚    β”‚     D1       β”‚    β”‚  (Frontend)  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  (Storage)   β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚
β”‚                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack:

  • Frontend: Astro 5.14 + React 19 + Tailwind CSS 4
  • Email Worker: Cloudflare Email Worker + postal-mime
  • Database: Cloudflare D1 (SQLite)
  • Authentication: JWT (jose)
  • UI Components: Radix UI + shadcn/ui
  • Validation: Zod + React Hook Form

πŸ“‹ Prerequisites

  • Node.js >= 18
  • pnpm >= 8
  • Cloudflare account with:
    • Email routing enabled
    • D1 database created
    • Turnstile site configured

πŸš€ Quick Start

1. Clone and Install

git clone https://github.com/yourusername/cloudflare-vmails.git
cd cloudflare-vmails
pnpm install

2. Configure Cloudflare D1

Create a D1 database:

cd apps/astro
wrangler d1 create vmail-db

Apply database schema:

cd ../emails-worker
wrangler d1 execute vmail-db --file=../../packages/database/schema.sql

3. Configure Environment

Create apps/astro/wrangler.toml:

# :schema node_modules/wrangler/config-schema.json
name = "vmail-app"
compatibility_date = "2024-09-25"
pages_build_output_dir = "./dist"

[vars]
# Cloudflare Turnstile (https://dash.cloudflare.com/?to=/:account/turnstile)
TURNSTILE_SECRET = "your-turnstile-secret"
TURNSTILE_SITE_KEY = "your-turnstile-site-key"

# Email configuration
MAIL_DOMAIN = "your-domain.com"

# Security
JWT_SECRET = "your-random-jwt-secret-min-32-chars"
COOKIE_EXPIRES_IN_SECONDS = 86400  # 24 hours

# Site information
SITE_NAME = "Your VMail Service"
SITE_DESCRIPTION = "Privacy-focused temporary email service"

# Optional: Email sending via Mailgun
# MAILGUN_BASE_URL = "https://api.mailgun.net"
# MAILGUN_API_KEY = "your-mailgun-api-key"
# MAILGUN_SEND_DOMAIN = "your-mailgun-domain.com"

[[d1_databases]]
binding = "DB"  # DO NOT CHANGE
database_name = "vmail-db"
database_id = "your-database-id"

Create apps/emails-worker/wrangler.toml:

name = "vmail-email-worker"
compatibility_date = "2024-09-25"
main = "src/index.ts"

[[d1_databases]]
binding = "DB"  # DO NOT CHANGE
database_name = "vmail-db"
database_id = "your-database-id"

4. Configure Email Routing

  1. Go to Cloudflare Dashboard
  2. Select your domain β†’ Email β†’ Email Routing
  3. Enable Email Routing
  4. Add a Catch-all route pointing to your email worker

5. Development

# Start development servers
pnpm dev

# Or start individually
pnpm --filter astro dev        # Frontend at http://localhost:4321
pnpm --filter email-worker dev # Email worker

6. Deploy

# Deploy email worker first
cd apps/emails-worker
pnpm deploy

# Deploy frontend
cd ../astro
pnpm deploy

πŸ“ Project Structure

emails/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ astro/              # Frontend application
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ actions/    # Astro server actions
β”‚   β”‚   β”‚   β”œβ”€β”€ components/ # React & Astro components
β”‚   β”‚   β”‚   β”œβ”€β”€ content/    # MDX documentation
β”‚   β”‚   β”‚   β”œβ”€β”€ layouts/    # Page layouts
β”‚   β”‚   β”‚   β”œβ”€β”€ lib/        # Utilities
β”‚   β”‚   β”‚   └── pages/      # Route pages
β”‚   β”‚   └── wrangler.toml
β”‚   └── emails-worker/      # Email receiver worker
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   └── index.ts
β”‚       └── wrangler.toml
└── packages/
    └── database/           # Shared database package
        β”œβ”€β”€ dao.ts          # Data access layer
        β”œβ”€β”€ db.ts           # Database client
        └── schema.sql      # Database schema

πŸ”‘ Key Features Explained

Mailbox Types

Temporary Mailbox

  • No registration required
  • Valid for 24 hours (configurable)
  • Anyone with the mailbox ID can access

Claimed Mailbox

  • Password protected
  • Permanent storage
  • Private and secure

OTP Detection

Automatically detects and extracts verification codes from emails:

  • 6-digit codes (123456)
  • Alphanumeric codes (A1B2C3)
  • Time-sensitive OTP formats

Security Features

  • JWT-based authentication
  • Cloudflare Turnstile bot protection
  • CORS and rate limiting ready
  • Password hashing for claimed mailboxes
  • Automatic email expiration

🎨 Customization

Styling

The project uses Tailwind CSS 4 with CSS variables for theming. Customize colors in apps/astro/src/globals.css:

:root {
  --background: 0 0% 100%;
  --foreground: 0 0% 3.9%;
  --primary: 0 0% 9%;
  /* ... more variables */
}

Email Domains

Add multiple domains in your wrangler.toml by setting up email routing for each domain and updating the MAIL_DOMAIN variable.

πŸ“ Commands

# Development
pnpm dev              # Start all services
pnpm dev:apps         # Start apps only
pnpm dev:packages     # Build packages in watch mode

# Building
pnpm build            # Build all packages and apps
pnpm build:apps       # Build apps only
pnpm build:packages   # Build packages only

# Type checking
pnpm type-check       # Check types
pnpm type-check:watch # Check types in watch mode

# Linting
pnpm lint             # Lint all projects

# Deployment
pnpm deploy           # Build and deploy all

# Cleanup
pnpm clean            # Clean all build outputs

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“§ Support

If you have any questions or need help, please:

  • Open an issue on GitHub
  • Check the documentation
  • Review existing issues and discussions

Made with ❀️ using Cloudflare's edge network

About

πŸ“« An open source temporary email tool, fully on Cloudflare. Inspired by oiov/vmail

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published