A modern email hosting platform that allows you to set up custom domains and create professional email addresses like mailbox@hosenur.dev, accessible through your domain at mailbox.hosenur.dev.
- Custom Domain Setup: Host email for your own domain (e.g.,
hosenur.dev) - Professional Email Addresses: Create addresses like
mailbox@hosenur.dev,info@hosenur.dev, etc. - Domain-Based Access: Users log in via their subdomain (e.g.,
mailbox.hosenur.dev) - Subdomain Routing: Each email address gets its own subdomain for organized access
- Real-time Inbox: Live email updates using Resend's inbound API
- Email Organization: Starred, sent, archived, and trash folders
- Advanced Search: Search through emails by subject, sender, or content
- Responsive Design: Works seamlessly on desktop and mobile devices
- AI Summaries: Optional AI-generated summaries for better email comprehension
- TLDR Generation: Quick summaries of unread emails
- Smart Categorization: Automatic email categorization (Work, Personal, Finance, etc.)
- Action Items Extraction: Identify actionable tasks from emails
- Secure Authentication: Built with Better Auth for robust user management
- Avatar Generation: Automatic avatar creation using DiceBear
- Session Management: Secure session handling with IP and user agent tracking
- Beautiful Interface: Built with React Aria Components and Tailwind CSS 4
- Dark/Light Theme: Theme switching support with next-themes
- Accessible: Full accessibility support with React Aria
- Smooth Animations: Motion-powered animations for enhanced UX
- Next.js 16 - React framework with Pages Router
- React 19 - Latest React with React Compiler
- TypeScript 5 - Type-safe development
- Tailwind CSS 4 - Utility-first CSS framework
- React Aria Components - Accessible UI components
- Biome - Fast linter and formatter
- Next.js API Routes - Server-side API endpoints
- Prisma ORM - Type-safe database access
- PostgreSQL - Robust relational database
- Better Auth - Authentication library
- Resend Inbound API - Receive emails for custom domains
- Resend - Email service for sending emails
- Domain-based Routing - Subdomain-based email access
- SWR - Data fetching and caching
- Mistral AI - Email summarization and analysis (optional)
- DiceBear - Avatar generation
src/
βββ components/ # Reusable UI components
β βββ ui/ # Base UI components (buttons, inputs, etc.)
β βββ icons/ # Custom icon components
β βββ app-sidebar.tsx # Main navigation sidebar
β βββ email-sidebar.tsx # Email list sidebar
β βββ email-preview.tsx # Email preview component
βββ hooks/ # Custom React hooks
βββ lib/ # Utility libraries
β βββ auth.ts # Authentication configuration
β βββ resend.ts # Resend API integration
β βββ prisma.ts # Database client
β βββ primitive.ts # Utility functions
βββ pages/ # Next.js pages and API routes
β βββ api/ # API endpoints
β β βββ portal.ts # Resend inbound email handler
β β βββ emails.ts # Email management
β β βββ tldr.ts # TLDR generation
β βββ auth/ # Authentication pages
β βββ s/ # Subdomain-based email interface
βββ styles/ # Global styles
βββ layout/ # Layout components
- Node.js 18+
- PostgreSQL database
- Resend account with inbound email enabled
- Custom domain for email hosting
-
Clone the repository
git clone <your-repo-url> cd email
-
Install dependencies
bun install # or npm install # or yarn install
-
Set up environment variables Create a
.env.localfile:# Database DATABASE_URL="postgresql://username:password@localhost:5432/email_db" # Resend RESEND_API_KEY="your_resend_api_key" # Better Auth BETTER_AUTH_SECRET="your_better_auth_secret" # Optional: Mistral AI MISTRAL_API_KEY="your_mistral_api_key"
-
Set up the database
# Generate Prisma client bun db:generate # Run database migrations bun db:migrate # (Optional) Open Prisma Studio bun db:studio
-
Start the development server
bun dev # or npm run dev
The application will be available at http://localhost:3000.
Set up your domain (e.g., hosenur.dev) with the following DNS records:
# MX Records
MX 10 inbound-smtp.us-east-1.amazonses.com.
# TXT Records for SPF, DKIM (provided by Resend)
TXT "v=spf1 include:amazonses.com ~all"
# DKIM records (provided by Resend dashboard)
Create DNS records for your email subdomains:
# For mailbox access (mailbox.hosenur.dev)
CNAME mailbox your-domain.com
# For other email addresses
CNAME info your-domain.com
CNAME support your-domain.com
- Add your domain to Resend dashboard
- Enable inbound email for your domain
- Set webhook URL to:
https://yourdomain.com/api/portal
Users can create email addresses through the platform:
mailbox@hosenur.devβ accessible atmailbox.hosenur.devinfo@hosenur.devβ accessible atinfo.hosenur.devsupport@hosenur.devβ accessible atsupport.hosenur.dev
The application uses PostgreSQL with the following main entities:
- User: User accounts and profile information
- Email: Email messages with metadata and content
- Session: User sessions for authentication
- Account: OAuth account connections
- Verification: Email verification tokens
Key email fields:
recipient: The email address that received the messagefrom: Sender informationsubject: Email subject linetextBody/htmlBody: Email contentsummary: AI-generated summary (optional)category: Email category (Work, Personal, etc.)opened: Read status
GET /api/emails- Fetch user's emailsGET /api/emails/[id]- Get specific emailGET /api/search- Search emailsGET /api/tldr- Generate TLDR summary (optional)
POST /api/portal- Resend webhook for inbound emails- Processes incoming emails via Resend inbound API
- Stores emails in database with AI analysis (if enabled)
GET /api/users- User management- Authentication endpoints via Better Auth
- Incoming Email: Email sent to
mailbox@hosenur.dev - Resend Processing: Resend receives email and forwards to webhook
- Webhook Handler:
/api/portalprocesses the email - Database Storage: Email stored in PostgreSQL with metadata
- User Notification: User sees new email in real-time interface
- AI Analysis (Optional): Mistral AI analyzes and categorizes email
- Domain Verification: Ensures emails are from verified domains
- Authentication: Secure user authentication with Better Auth
- Session Management: Automatic session handling with security features
- CSRF Protection: Built-in CSRF protection
- Input Validation: Zod schema validation for API inputs
The application includes a comprehensive UI component library:
- Buttons: Various button styles and states
- Forms: Input fields, text areas, and form controls
- Navigation: Sidebars, breadcrumbs, and menus
- Data Display: Tables, lists, cards, and charts
- Feedback: Toasts, loaders, and progress indicators
- Overlays: Modals, dialogs, and popovers
# Development
bun dev # Start development server
# Building
bun build # Production build
bun start # Start production server
# Code Quality
bun lint # Run Biome linter
bun format # Format code with Biome
# Database
bun db:generate # Generate Prisma client
bun db:migrate # Run database migrations
bun db:push # Push schema changes
bun db:studio # Open Prisma Studio- Formatting: 2-space indentation, enforced by Biome
- Linting: Biome linter with React and Next.js rules
- TypeScript: Strict TypeScript configuration
- Imports: Organized with path aliases (
@/*forsrc/*)
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Configure custom domains in Vercel
- Deploy automatically on push
- Build the application:
bun build - Start the production server:
bun start - Ensure PostgreSQL database is accessible
- Configure environment variables
- Set up domain DNS records
- Domain Setup: Configure DNS for
hosenur.dev - Create User: Register user for
mailbox@hosenur.dev - Access Email: User visits
mailbox.hosenur.dev - Receive Emails: Emails sent to
mailbox@hosenur.devappear in the interface - Send Replies: Use Resend API to send responses
company.comβ users access viamailbox.company.compersonal.netβ users access viainbox.personal.net- Each domain operates independently with its own email addresses
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following the code style guidelines
- Run linting and formatting:
bun lint && bun format - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Resend for excellent email infrastructure and inbound API
- Better Auth for robust authentication
- React Aria for accessible UI components
- Prisma for excellent database tooling
- Next.js team for the amazing framework
For support, email support@yourdomain.com or join our Discord community.
Built with β€οΈ using Next.js, Resend, and modern web technologies