Skip to content
/ mailer Public

A simple and efficient Node.js microservice for sending emails via a REST API, designed for easy integration.

Notifications You must be signed in to change notification settings

tsxr1ck/mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailer Microservice

A simple Node.js microservice for sending emails using Express and Nodemailer. Designed for easy integration with other applications via a single POST endpoint.

Features

  • Send emails via a REST API
  • CORS enabled for frontend integration
  • Environment-based configuration for security (dotenv)
  • Supports both development and production environments

Requirements

  • Node.js (v16 or newer recommended)
  • pnpm (or npm/yarn)

Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/mailer.git
    cd mailer
  2. Install dependencies:

    pnpm install
    # or
    npm install
  3. Configure environment variables:

    • Copy .env.development and .env.production and fill in your SMTP credentials.
    • Never commit your real credentials to git!
  4. Run in development:

    node server.js
  5. Run in production:

    set NODE_ENV=production && node server.js

API

POST /send-email

Send an email via the service.

Request Body (JSON):

{
  "to": "recipient@example.com",
  "subject": "Email Subject",
  "html": "<b>Hello!</b>",
  "appName": "YourAppName"
}

Response:

  • 200 OK on success
  • 400 if required fields are missing
  • 500 on server error

Security

  • SMTP credentials are loaded from environment files using dotenv.
  • All .env* files are gitignored by default.

License

MIT

About

A simple and efficient Node.js microservice for sending emails via a REST API, designed for easy integration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published