A temporary email service with a modern UI that allows users to create disposable email addresses and receive emails without registration.
The project consists of two main parts:
- Built with Next.js 15
- Uses React with TypeScript
- Styled with Tailwind CSS
- Fully responsive design for mobile, tablet, and desktop
- Located in the
/frontenddirectory
- Node.js with Express
- TypeScript
- SMTP server for receiving emails
- PostgreSQL database with Prisma ORM
- Robust error handling and recovery
- Located in the
/backenddirectory
- Node.js (v18+)
- PostgreSQL
- pnpm (recommended) or npm
- Navigate to the backend directory:
cd backend- Install dependencies:
pnpm install- Set up environment variables:
Create a .env file in the backend directory with the following content:
# Database
DATABASE_URL=
# Frontend URL for CORS
FRONTEND_URL=
CORS_ORIGIN=
# Backend Configuration
API_PORT=3001
SMTP_PORT=25
# SMTP Configuration
SMTP_DOMAIN=
# Environment
NODE_ENV=production
- Run database migrations:
pnpm prisma migrate dev- Start the backend server:
# Development mode
pnpm dev
# Production mode
pnpm build
pnpm start- Navigate to the frontend directory:
cd frontend- Install dependencies:
pnpm install- Set up environment variables:
Create a .env file in the frontend directory with the following content:
NEXT_PUBLIC_API_BASE=
- Start the frontend development server:
# Development mode
pnpm dev
# Production mode
pnpm build
pnpm start- Open http://localhost:3000 in your browser to see the application.
The backend is built with Node.js and Express, providing both an API server and an SMTP server for receiving emails.
- API Server: Handles HTTP requests for creating mailboxes and retrieving messages
- SMTP Server: Receives incoming emails and stores them in the database
- Database: PostgreSQL with Prisma ORM for data storage and retrieval
- Auto-Creation: Automatically creates mailboxes when needed for resilience
- Cleanup Service: Automatically removes expired emails after 24 hours
- Health Check: Endpoint to verify backend server status
- Rate Limiting: Intelligent rate limiting that works in production environments with proxies
The backend implements different rate limits based on endpoint sensitivity:
- Mailbox Creation: 5 requests per 5 minutes
- Message Access: 30 requests per 1 minute
- General API Access: 100 requests per 15 minutes
Rate limiting is proxy-aware and correctly identifies client IPs using:
- X-Forwarded-For header (common in AWS and other cloud providers)
- CF-Connecting-IP header (used by Cloudflare)
- X-Real-IP header (used by various proxies)
- Direct IP as fallback
GET /api/health- Health check endpointPOST /api/mailboxes/custom- Create a custom mailboxPOST /api/mailboxes/:address/messages- Get messages for a mailboxGET /api/messages/:id- Get a specific message
The database uses Prisma ORM with the following main models:
Mailbox: Represents a temporary email addressMessage: Stores received emails with their content and metadata
The frontend is built with Next.js 15 and React, providing a responsive and modern user interface.
- Home Page: Allows users to create custom email addresses
- Mailbox Page: Displays received emails with auto-refresh functionality
- Message Detail Page: Shows the full content of an email with HTML support
- Next.js: React framework with App Router
- React: UI library for building components
- TypeScript: Type-safe JavaScript
- Tailwind CSS: Utility-first CSS framework
- Sonner: Toast notifications
- React hooks for local state management
- Smart polling with exponential backoff for API requests
- Cache-busting for fresh data
- Error resilience with graceful degradation
- Mobile-first approach with adaptive layouts
- Optimized viewing experience on all device sizes
- Touch-friendly interface elements
- Responsive typography and spacing
# Backend tests
cd backend
pnpm test
# Frontend tests
cd frontend
pnpm test# Build backend
cd backend
pnpm build
# Build frontend
cd frontend
pnpm buildThe backend can be deployed to any Node.js hosting service:
- Set up the environment variables as described above
- Build the project:
pnpm build - Start the server:
pnpm start
The frontend can be deployed to Vercel or any static hosting service:
- Set up the environment variables as described above
- Build the project:
pnpm build - Deploy the
.nextfolder
- Re-implemented production-ready rate limiting that works with proxies and load balancers
- Improved IP detection to handle X-Forwarded-For, CF-Connecting-IP, and X-Real-IP headers
- Added robust error handling and auto-recovery mechanisms
- Implemented automatic mailbox creation for resilience
- Enhanced database connection error handling
- Improved logging for better debugging and monitoring
- Implemented fully responsive design for all screen sizes
- Enhanced error handling with graceful degradation
- Added cache-busting for reliable data fetching
- Improved UI with consistent button sizing and styling
- Optimized email content display for mobile devices
- Fixed scrolling issues for long email content
- Enhanced visual feedback during loading states
