Atlas Mailer Integration¶
The atlas-mailer is a decoupled microservice designed to handle email dispatching via Gmail SMTP. It runs on Cloudflare Workers and provides a secure, rate-limited API for sending emails.
Features¶
- Decoupled Architecture: Email logic is isolated from the main API.
- Rate Limiting: Enforces a strict limit of 500 emails per day (tracked via Cloudflare KV).
- Secure: Authenticates incoming requests via a Bearer token.
- Gmail SMTP: Uses Nodemailer with Gmail's SMTP servers.
Configuration¶
To use the atlas-mailer as your email provider in the main Atlas API, update your environment variables.
Environment Variables (apps/api/.env)¶
| Bash | |
|---|---|
How it works¶
- The main Atlas API
EmailServicedetects thatEMAIL_PROVIDERis set toatlas-mailer. - Instead of sending emails directly via SMTP or Brevo, it makes a
POST /sendrequest to theatlas-mailerURL. - The request includes the
Authorizationheader with theAPI_KEY. - The
atlas-mailermicroservice:- Validates the API key.
- Checks the daily quota in Cloudflare KV.
- Sends the email using Gmail SMTP.
- Increments the daily usage counter.
Repository¶
The source code for the microservice can be found at: https://github.com/VaibhavDaveDev/atlas-mailer
Local Development¶
If you want to run the mailer locally for testing:
- Clone the repo:
git clone https://github.com/VaibhavDaveDev/atlas-mailer.git - Install dependencies:
pnpm install - Create
.dev.varswith your Gmail credentials and API key. - Run locally:
pnpm run dev - Update
ATLAS_MAILER_URLin the main API tohttp://localhost:8787.