open-mail-sender is a minimal API service to send emails using Nodemailer and external SMTP servers. Built with Node.js, MongoDB, and Docker — easy to self-host and extend.
- single
POST /send-mailAPI - send plain or HTML emails
- optional wait vs background delivery
- API key–based auth
- MongoDB mail logging
- docker-ready
-
clone the repo
git clone https://github.com/Abhay-Vachhani/open-mail-sender cd open-mail-sender -
create
.envcp .env.example .env
fill in your SMTP and MongoDB credentials
-
run in development
docker compose -f docker-compose.dev.yml up --build
-
run in production
docker compose up --build -d
headers
x-api-key: your-api-key
content-type: application/json
body
{
"to": "test@example.com",
"subject": "hello",
"text": "plain text",
"html": "<b>optional html</b>",
"wait": true
}response (wait = true)
{
"message": "email sent",
"messageId": "abc123"
}response (wait = false)
{
"message": "email send queued",
"logId": "..."
}- uses
x-api-keyheader for client auth - set
API_KEYin.env - SMTP credentials are never exposed to the client
# generate a new api key
yarn generate-key.
├── index.js → express app + routes
├── models/ → mongoose models
├── generate-api-key.js → simple CLI tool
├── .env / .env.example → environment config
├── docker-compose.yml → mongo + app container
└── readme.md