- Custom Domains - Add and verify your own domains
 - Full Email Server - Built-in SMTP/IMAP with DKIM signing
 - Multi-Tenant - Manage organizations and users
 - Object Storage - Cloudflare R2 for attachments
 - Real-time - Kafka event streaming
 - Analytics - Dashboard with metrics
 
Runtime & Framework
- Bun, Hono, Next.js 15
 
Database & Cache
- PostgreSQL, Drizzle ORM, Redis
 
Storage & Messaging
- Cloudflare R2, Apache Kafka
 
- Custom SMTP/IMAP servers, DKIM authentication
 
Payments
- DodoPayments integration
 
- Bun 1.1.34+
 - PostgreSQL 14+
 - Redis 7+
 
git clone https://github.com/Bas3line/rawmail.git
cd rawmail
bun installapps/api/.env:
PORT=3001
DATABASE_URL=postgresql://user:password@localhost:5432/rawemail
REDIS_URL=redis://localhost:6379
JWT_SECRET=your-secret-key
MAIL_SERVER_HOSTNAME=mail.yourdomain.com
MAIL_SERVER_IP=your-server-ip
R2_ACCOUNT_ID=your-cloudflare-account-id
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=rmail-attachments
R2_PUBLIC_URL=https://pub-xxxxx.r2.devapps/web/.env:
NEXT_PUBLIC_API_URL=http://localhost:3001cd packages/database
bun run generate
bun run migratecd apps/api && bun run dev
cd apps/web && bun run dev# Copy environment template
cp .env.example .env
# Edit .env with your configuration
nano .env
# Build and run with docker-compose
docker-compose up -d
# View logs
docker-compose logs -f app
# Stop services
docker-compose downAuth: /api/auth/register, /api/auth/login
Domains: /api/domains, /api/domains/:id/verify
Emails: /api/emails, /api/emails/:id
Analytics: /api/analytics/stats, /api/analytics/email-volume
When adding a domain, configure these records:
- MX - Mail server routing
 - SPF - Sender authorization
 - DKIM - Email signing
 - DMARC - Email policy
 - TXT - Domain verification
 
The unified Dockerfile builds and runs both API and web services in a single container:
# Set environment variables
export DATABASE_URL=postgresql://user:password@host:5432/dbname
export JWT_SECRET=your-secret-key
export R2_ACCOUNT_ID=your-account-id
# ... set other vars from .env.example
# Build with environment
docker build --build-arg DATABASE_URL="$DATABASE_URL" -t rmail:latest .
# Run container
docker run -d \
  -p 3000:3000 \
  -p 3001:3001 \
  -e DATABASE_URL="$DATABASE_URL" \
  -e JWT_SECRET="$JWT_SECRET" \
  -e R2_ACCOUNT_ID="$R2_ACCOUNT_ID" \
  # ... add other environment variables
  -v $(pwd)/logs:/app/logs \
  --name rmail \
  rmail:latest# Includes Redis, Kafka, and Zookeeper
docker-compose up -dThe container automatically:
- Runs database migrations
 - Tests database connectivity
 - Starts API server (port 3001)
 - Starts web server (port 3000)
 - Provides health checks
 - Outputs logs to /app/logs/
 
Kira - kiraa@tuta.io
MIT License