A minimal mailing-list manager that stores recipients, generates HTML messages, and sends broadcasts via SMTP.
- Install:
npm install - Dev:
npm run dev - Preview (prod env):
npm run preview - Prod build:
npm run build - Prod start:
npm start
SMTP_HOST: SMTP host (default:smtp.gmail.com)SMTP_PORT: SMTP port (default:587)SMTP_SECURE:true|false(default:false— uses STARTTLS)SMTP_USER/SMTP_PASS: SMTP credentialsMAIL_FROM: default From address (optional)BASE_URL: public base URL used to build unsubscribe links (e.g.https://example.com)API_KEY: admin key for protected endpoints (sent inx-api-keyorAuthorization: Bearer)
Config file: src/configs/mailConfig.ts
- Mail utilities: src/utils/mailUtils.ts
- Model: src/models/mailListModel.ts
- Services: src/services/mailServices.ts
- Controllers: src/controllers/mailListController.ts, src/controllers/unsubscribeController.ts
- Routers: src/routers/mailingRouter.ts, src/routers/unsubscribeRouter.ts
- HTML helper: src/helpers/generateHtml.ts
GET /— health messageGET /api/mailing-list— list recipients (protected)POST /api/mailing-list— add one or many recipients (protected). Body: array or single{ name, email }.PUT /api/mailing-list— update one or many recipients (protected). Body: item(s) withidoremailandupdate.DELETE /api/mailing-list— delete one or many byemail,_id, oruuid(protected). Body:{ identifiers: string | string[] }.POST /api/mailing-list/send— trigger broadcast send (protected). Body: optionalsubjectandtext. Returns202and immediately queues send.GET /unsubscribe?uuid=<uuid>— public unsubscribe link (no auth) — removes the recipient identified byuuid.
- Each recipient gets a
uuidused to identify unsubscribe requests; unsubscribe URLs are generated asBASE_URL + '/unsubscribe?uuid=' + uuid. - The
/sendendpoint performs fire-and-forget sending and returns a202with queued count. Delivery errors are logged server-side. - For REST Client testing, see
src/test.
- Use the
.httpfiles insrc/testto add/list/send/unsubscribe.
