Email Services is a Node.js and Express API for testing and sending transactional emails through multiple email providers. The currently wired HTTP routes support SendGrid, Resend, and Brevo. The repository also includes controller or SMTP examples for Mailgun, Postmark, and Nodemailer-based provider setups.
- Starts an Express server with JSON request parsing.
- Provides provider-specific email sending endpoints.
- Loads API keys and server configuration from environment variables.
- Keeps each provider's email sending logic in a separate controller file.
- Includes example service files showing SMTP transporter settings for common email providers.
- Node.js
- Express
- dotenv
- SendGrid SDK
- Resend SDK
- Brevo SDK
- Mailgun SDK
- Postmark SDK
- Nodemailer
.
+-- controllers/ # Email sending logic for each provider
+-- routes/ # Express routes for active provider endpoints
+-- services/ # SMTP transporter examples
+-- server.js # Express app entry point
+-- package.json # Scripts and dependencies
+-- .env.example # Example environment variables
`-- README.md
npm installCreate a .env file in the project root. You can start by copying .env.example:
cp .env.example .envOn Windows PowerShell:
Copy-Item .env.example .envUpdate .env with your real provider keys:
PORT=4000
SENDGRID_API_KEY=your-sendgrid-api-key
RESEND_API_KEY=your-resend-api-key
BREVO_API_KEY=your-brevo-api-key
MAILGUN_API_KEY=your-mailgun-api-key
POSTMARK_API_KEY=your-postmark-api-keyDo not commit .env. It is already ignored by .gitignore.
Before sending real emails, update the placeholder sender and recipient values in the provider controller you want to use:
controllers/sendgridEmail.jscontrollers/resendEmail.jscontrollers/brevoEmail.jscontrollers/mailgunEmail.jscontrollers/postmarkEmail.js
For example, replace placeholder values such as hello@yourdomain.com, empty to fields, and sample recipient strings with verified sender and recipient email addresses supported by your provider account.
For production-style startup:
npm startFor development with automatic restarts:
npm run serverBy default, the server runs on:
http://localhost:4000
GET /Returns a basic JSON response showing that the server is running.
POST /api/sendgrid/send-emailUses SENDGRID_API_KEY and the email details configured in controllers/sendgridEmail.js.
POST /api/resend/send-emailUses RESEND_API_KEY and the email details configured in controllers/resendEmail.js.
POST /api/brevo/send-emailUses BREVO_API_KEY and the email details configured in controllers/brevoEmail.js.
The current controllers use hard-coded example email payloads, so the request body is not required yet.
curl -X POST http://localhost:4000/api/resend/send-emailIf the provider key and email settings are valid, the server responds with a success message and provider response data where available.
npm startRuns the server with Node.
npm run serverRuns the server with Nodemon for development.
npm testCurrently returns the default placeholder test error. No automated tests are configured yet.
- SendGrid, Resend, and Brevo are currently connected to Express routes.
- Mailgun and Postmark controller files exist, but their routes are not currently mounted in
server.js. - Some files in
services/are SMTP transporter examples and are not imported by the active server code. - Most email providers require verified sender domains or sender addresses before they allow production email delivery.