Zapmail requires specific environment variables to connect the backend SMTP server, frontend web interface, and PostgreSQL database.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Parth-420/Zapmail/llms.txt
Use this file to discover all available pages before exploring further.
Backend environment variables
The Go SMTP server requires these environment variables:PORT
The TCP port number for the SMTP server to listen on.
2525- Standard alternative SMTP port (recommended)25- Standard SMTP port (requires root on Linux)587- Submission port- Any custom port number
SUPABASE_CONN_STRING
PostgreSQL connection string for database access.
Despite the variable name containing “SUPABASE”, this can be any PostgreSQL connection string, not just Supabase.
Frontend environment variables
The Next.js web interface requires these environment variables:DATABASE_URL
PostgreSQL connection string for the frontend database connection pool.
Configuration files
Backend .env file
Create a.env file in the backend directory:
github.com/joho/godotenv to load environment variables from .env (backend/main.go:28-33):
If no
.env file is found, the server will log a warning but continue if environment variables are set through other means (system environment, Docker, etc.).Frontend .env.local file
Create a.env.local file in the ui directory:
Database schema
Both backend and frontend require the following PostgreSQL table:id- Auto-incrementing primary keyusername- Extracted from email recipient (part before @)recipient- Full recipient email addressraw_data- Complete raw email content including headersreceived_at- Timestamp when email was received
Advanced configuration
Connection pool settings
For production deployments, you may want to configure the PostgreSQL connection pool in the frontend:SMTP server customization
The SMTP server behavior is configured in code. To customize: Cleanup interval (backend/main.go:197):Next.js configuration
The Next.js configuration can be extended inui/next.config.ts:
Platform-specific configuration
Vercel
Add environment variables in the Vercel dashboard:- Go to Project Settings > Environment Variables
- Add
DATABASE_URLwith your PostgreSQL connection string - Select appropriate environments (Production, Preview, Development)
Railway
Railway can auto-provision PostgreSQL:- Add PostgreSQL plugin to your project
- Railway automatically provides
DATABASE_URL - For backend, add
PORTandSUPABASE_CONN_STRING(use Railway’sDATABASE_URL)
Docker Compose
Example configuration with all services:Security best practices
Restrict database access
Configure PostgreSQL to only accept connections from your application servers.
Troubleshooting
Environment variable not found
If you see “PORT environment variable not set”:- Check the variable is defined in
.envor system environment - Ensure variable names match exactly (case-sensitive)
- Restart the application after changing environment variables
Database connection failed
If you see “Error connecting to DB” or “Cannot ping DB”:- Verify the connection string format is correct
- Test the connection with
psql: - Check network access and firewall rules
- Verify database credentials are correct
Frontend can’t read environment variables
In Next.js:- Server-side variables (like
DATABASE_URL) are only available in API routes and server components - Client-side variables must be prefixed with
NEXT_PUBLIC_ - Restart the dev server after changing
.env.local
The
DATABASE_URL is server-side only and cannot be accessed from client components.Next steps
Backend setup
Deploy the Go SMTP server
Frontend setup
Deploy the Next.js interface