* draft fixes: - added cc and bcc when saving drafts - save drafts less aggresively * some fixes for saving attachments to draft * fix for empty draft loading * fix draft list recipient name/address * also show 'No Recipient' if empty * remove comments * switch to mimetext for draft saving to keep formatting consistent * add message title to draft list * feat: single api for oauth connections * fix: add extra error handling * chore: simplify and fix the dev env * Ai generate security (#706) * Create prompts with XML formatting * Include XML formatted prompts in generate func * remove unused regex and add helper functions/warnings * error handling * Update apps/mail/lib/prompts.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * lint issues * Update prompts.ts * https://github.com/Mail-0/Zero/pull/706#discussion_r2049650081 Coderabbit fix 1 * erabbitai bot 3 days ago ⚠️ Potential issue errorOccurred state is stale inside finally React state setters (setErrorOccurred) are asynchronous; the errorOccurred value captured at render time will not yet reflect changes made earlier in the same event loop. Consequently, the logic deciding whether to collapse/expand may run with an outdated flag. - } finally { - setIsLoading(false); - if (!errorOccurred || isAskingQuestion) { - setIsExpanded(true); - } else { - setIsExpanded(false); // Collapse on errors - } - } + } finally { + setIsLoading(false); + // Use a local flag to track errors deterministically + const hadError = isAskingQuestion ? false : !!errorFlagRef.current; + setIsExpanded(!hadError); + } You can create const errorFlagRef = useRef(false); and update errorFlagRef.current = true every time an error is detected, ensuring reliable behaviour irrespective of React batching. Committable suggestion skipped: line range outside the PR's diff. * https://github.com/Mail-0/Zero/pull/706#discussion_r2049650112 * https://github.com/Mail-0/Zero/pull/706#discussion_r2049650106 * https://github.com/Mail-0/Zero/pull/706#discussion_r2049650097 --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Add a new Vietnamese translation file to support Vietnamese language users (#726) * feat(i18n): add Vietnamese language support Add Vietnamese ('vi') to the list of supported languages in the i18n configuration and JSON file to expand language options. * Add a new Vietnamese translation file to support Vietnamese language users. * Clear Vietnamese translation strings * Update es.json (#710) Co-authored-by: needle <122770437+needleXO@users.noreply.github.com> * Update app manifest and add new icons for PWA (#739) * feat: allow sending from email aliases added through gmail (#743) * Refactor IP handling in early-access routes * Add unauthorized error handling in sign out function --------- Co-authored-by: Ahmet Kilinc <akx9@icloud.com> Co-authored-by: BlankParticle <blankparticle@gmail.com> Co-authored-by: grim <75869731+ripgrim@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Chánh Đại <dai@chanhdai.com> Co-authored-by: Dani B. <danibaldomirm@gmail.com> Co-authored-by: needle <122770437+needleXO@users.noreply.github.com> Co-authored-by: Humber Nieto <56887259+humbernieto@users.noreply.github.com> Co-authored-by: Atharva Deosthale <atharva.deosthale17@gmail.com>
9.5 KiB
Zero
An Open-Source Gmail Alternative for the Future of Email
What is Zero?
Zero is an open-source AI email solution that gives users the power to self-host their own email app while also integrating external services like Gmail and other email providers. Our goal is to modernize and improve emails through AI agents to truly modernize emails.
Why Zero?
Most email services today are either closed-source, data-hungry, or too complex to self-host. 0.email is different:
- ✅ Open-Source – No hidden agendas, fully transparent.
- 🦾 AI Driven - Enhance your emails with Agents & LLMs.
- 🔒 Data Privacy First – Your emails, your data. Zero does not track, collect, or sell your data in any way. Please note: while we integrate with external services, the data passed through them is not under our control and falls under their respective privacy policies and terms of service.
- ⚙️ Self-Hosting Freedom – Run your own email app with ease.
- 📬 Unified Inbox – Connect multiple email providers like Gmail, Outlook, and more.
- 🎨 Customizable UI & Features – Tailor your email experience the way you want it.
- 🚀 Developer-Friendly – Built with extensibility and integrations in mind.
Tech Stack
Zero is built with modern and reliable technologies:
- Frontend: Next.js, React, TypeScript, TailwindCSS, Shadcn UI
- Backend: Node.js, Drizzle ORM
- Database: PostgreSQL
- Authentication: Better Auth, Google OAuth
Getting Started
Prerequisites
Required Versions:
Before running the application, you'll need to set up services and configure environment variables. For more details on environment variables, see the Environment Variables section.
Setup Options
You can set up Zero in two ways:
Option 1: Standard Setup (Recommended)
Quick Start Guide
-
Clone and Install
# Clone the repository git clone https://github.com/Mail-0/Zero.git cd Zero # Install dependencies bun install # Start database locally bun docker:up -
Set Up Environment
- Copy
.env.exampleto.envin project rootcp .env.example .env - Configure your environment variables (see below)
- Start the database with the provided docker compose setup:
bun docker:up - Initialize the database:
bun db:push
- Copy
-
Start the App
bun dev -
Open in Browser
Visit http://localhost:3000
Option 2: Dev Container Setup (For VS Code Users)
This option uses VS Code's Dev Containers feature to provide a fully configured development environment with all dependencies pre-installed. It's great for ensuring everyone on the team has the same setup.
-
Prerequisites
- Docker
- VS Code or compatible editor
- Dev Containers extension
-
Open in Dev Container
- Clone the repository:
git clone https://github.com/Mail-0/Zero.git - Open the folder in VS Code
- When prompted, click "Reopen in Container" or run the "Dev Containers: Open Folder in Container" command
- VS Code will build and start the dev container (this may take a few minutes the first time)
- Clone the repository:
-
Access the App
- The app will be available at http://localhost:3000
-
Troubleshooting
- If you encounter issues with the container, try rebuilding it using the "Dev Containers: Rebuild Container" command
- For dependency issues inside the container:
bash rm -rf node_modules rm bun.lockb bun install
Environment Setup
-
Better Auth Setup
-
Open the
.envfile and change the BETTER_AUTH_SECRET to a random string. (Useopenssl rand -hex 32to generate a 32 character string)BETTER_AUTH_SECRET=your_secret_key
-
-
Google OAuth Setup (Required for Gmail integration)
-
Go to Google Cloud Console
-
Create a new project
-
Add the following APIs in your Google Cloud Project: People API, Gmail API
- Use the links above and click 'Enable' or
- Go to 'APIs and Services' > 'Enable APIs and Services' > Search for 'Google People API' and click 'Enable'
- Go to 'APIs and Services' > 'Enable APIs and Services' > Search for 'Gmail API' and click 'Enable'
-
Enable the Google OAuth2 API
-
Create OAuth 2.0 credentials (Web application type)
-
Add authorized redirect URIs:
- Development:
http://localhost:3000/api/auth/callback/google
- Production:
https://your-production-url/api/auth/callback/google
- Development:
-
Add to
.env:GOOGLE_CLIENT_ID=your_client_id GOOGLE_CLIENT_SECRET=your_client_secret -
Add yourself as a test user:
- Go to
Audience - Under 'Test users' click 'Add Users'
- Add your email and click 'Save'
- Go to
-
Warning
The authorized redirect URIs in Google Cloud Console must match exactly what you configure in the
.env, including the protocol (http/https), domain, and path - these are provided above.
Environment Variables
Copy .env.example located in the project folder to .env in the same folder and configure the following variables:
# Auth
BETTER_AUTH_SECRET= # Required: Secret key for authentication
# Google OAuth (Required for Gmail integration)
GOOGLE_CLIENT_ID= # Required for Gmail integration
GOOGLE_CLIENT_SECRET= # Required for Gmail integration
# Database
DATABASE_URL= # Required: PostgreSQL connection string for backend connection
# Redis
REDIS_URL= # Redis URL for caching (http://localhost:8079 for local dev)
REDIS_TOKEN= # Redis token (upstash-local-token for local dev)
For local development a connection string example is provided in the .env.example file located in the same folder as the database.
Database Setup
Zero uses PostgreSQL for storing data. Here's how to set it up:
-
Start the Database
Run this command to start a local PostgreSQL instance:
bun docker:upThis creates a database with:
- Name:
zerodotemail - Username:
postgres - Password:
postgres - Port:
5432
- Name:
-
Set Up Database Connection
Make sure your database connection string is in
.envfile.For local development use:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/zerodotemail" -
Database Commands
-
Set up database tables:
bun db:push -
Create migration files (after schema changes):
bun db:generate -
Apply migrations:
bun db:migrate -
View database content:
bun db:studioIf you run
bun devin your terminal, the studio command should be automatically running with the app.
-
Contribute
Please refer to the contributing guide.
If you'd like to help with translating Zero to other languages, check out our translation guide.
Star History
This project wouldn't be possible without these awesome companies
🤍 The team
Curious who makes Zero? Here are our contributors and maintainers