{"id":50439930,"url":"https://github.com/devhoangkien/mail-server","last_synced_at":"2026-05-31T18:31:11.563Z","repository":{"id":357101257,"uuid":"1235382224","full_name":"devhoangkien/mail-server","owner":"devhoangkien","description":"mail server with bun ","archived":false,"fork":false,"pushed_at":"2026-05-11T09:28:56.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-11T11:30:16.941Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devhoangkien.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-11T09:15:36.000Z","updated_at":"2026-05-11T09:29:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/devhoangkien/mail-server","commit_stats":null,"previous_names":["devhoangkien/mail-server"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/devhoangkien/mail-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhoangkien%2Fmail-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhoangkien%2Fmail-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhoangkien%2Fmail-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhoangkien%2Fmail-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devhoangkien","download_url":"https://codeload.github.com/devhoangkien/mail-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devhoangkien%2Fmail-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33744444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-31T18:31:10.800Z","updated_at":"2026-05-31T18:31:11.553Z","avatar_url":"https://github.com/devhoangkien.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BunMail 📬\n\nProduction mail server built entirely with **Bun** — blazing fast, zero Node.js dependencies.\n\n## Features\n\n- **SMTP** — Inbound (port 25) + Submission with auth (port 587)\n- **IMAP4rev1** — Full RFC 3501 implementation (port 143)\n- **REST API** — JSON API for webmail clients (port 3000)\n- **WebSocket** — Real-time new mail notifications\n- **DKIM** — Signs outbound mail, verifies inbound\n- **SPF** — Checks sender IP against DNS records\n- **Message Queue** — Redis-backed with retry + exponential backoff\n- **Maildir++** — Industry-standard mail storage format\n- **Rate Limiting** — Per-IP, per-account with Redis sliding window\n- **PostgreSQL** — Full ACID storage for users, mailboxes, messages\n\n## Quick Start\n\n### 1. Prerequisites\n\n```bash\n# Install Bun\ncurl -fsSL https://bun.sh/install | bash\n\n# Install PostgreSQL and Redis (or use Docker)\n```\n\n### 2. Clone and install\n\n```bash\ngit clone \u003crepo\u003e\ncd bunmail\nbun install\n```\n\n### 3. Start dependencies\n\n```bash\n# With Docker (easiest):\ndocker-compose up -d postgres redis\n\n# Or start PostgreSQL and Redis manually\n```\n\n### 4. Generate keys\n\n```bash\nbun scripts/gen-keys.ts\n```\n\n### 5. Configure\n\n```bash\ncp .env.example .env\n# Edit .env — at minimum set DOMAIN, HOSTNAME, JWT_SECRET\n```\n\n### 6. Run migrations and seed\n\n```bash\nbun run migrate\nbun run seed     # Creates alice@mail.local and bob@mail.local (password: password123)\n```\n\n### 7. Start the server\n\n```bash\n# Development (hot reload)\nbun run dev\n\n# Production\nbun run start\n```\n\n## DNS Records (Production)\n\nAdd these to your domain's DNS:\n\n```\n# MX Record\n@          MX  10  mail.yourdomain.com\n\n# SPF\n@          TXT     \"v=spf1 mx a:mail.yourdomain.com -all\"\n\n# DKIM (get value from certs/dkim-dns.txt after gen-keys)\nmail._domainkey  TXT  \"v=DKIM1; k=rsa; p=\u003cpublic-key\u003e\"\n\n# DMARC\n_dmarc     TXT  \"v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com\"\n```\n\n## API Reference\n\n### Auth\n\n```bash\n# Login\nPOST /api/auth/login\n{ \"email\": \"alice@mail.local\", \"password\": \"password123\" }\n→ { \"token\": \"...\", \"user\": { ... } }\n\n# Register\nPOST /api/auth/register\n{ \"email\": \"user@mail.local\", \"password\": \"...\", \"displayName\": \"...\" }\n```\n\n### Mailboxes\n\n```bash\nGET  /api/mailboxes              # List all mailboxes\nPOST /api/mailboxes              # Create mailbox { \"name\": \"Archive\" }\n```\n\n### Messages\n\n```bash\nGET  /api/mailboxes/:id/messages    # List messages (page, limit query params)\nGET  /api/messages/:id              # Get full message with HTML/text body\nPATCH /api/messages/:id             # Update flags { \"flags\": [\"\\\\Seen\"] }\nPOST /api/messages/send             # Send message\n     { \"to\": [...], \"subject\": \"...\", \"text\": \"...\", \"html\": \"...\" }\n```\n\n### Profile\n\n```bash\nGET /api/me    # Current user info + quota\n```\n\n## Architecture\n\n```\nsrc/\n├── index.ts              # Entry point — starts all servers\n├── core/\n│   ├── config.ts         # Zod-validated environment config\n│   ├── db.ts             # PostgreSQL queries (postgres.js)\n│   ├── queue.ts          # Redis queue + rate limiter + sessions\n│   └── storage.ts        # Maildir++ file storage\n├── smtp/\n│   ├── server.ts         # SMTP server (Bun.listen TCP)\n│   ├── delivery.ts       # Outbound delivery worker + retry\n│   └── dkim.ts           # DKIM signer + SPF checker\n├── imap/\n│   └── server.ts         # IMAP4rev1 server (RFC 3501)\n└── api/\n    └── routes.ts         # REST API + WebSocket (Bun.serve)\n```\n\n## Production Checklist\n\n- [ ] Set strong `JWT_SECRET` (32+ random chars)\n- [ ] Use real TLS certs (Let's Encrypt via certbot)\n- [ ] Configure firewall — open ports 25, 587, 143, 993\n- [ ] Set up DNS records (MX, SPF, DKIM, DMARC)\n- [ ] Run as non-root user (use `authbind` for port 25)\n- [ ] Set up log rotation\n- [ ] Configure backups for PostgreSQL and maildir\n- [ ] Consider adding ClamAV for virus scanning\n- [ ] Add SpamAssassin integration for spam filtering\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevhoangkien%2Fmail-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevhoangkien%2Fmail-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevhoangkien%2Fmail-server/lists"}