A simple Node.js backend project that sends emails using Nodemailer based on data received through an HTTP POST request.
- Send emails dynamically using JSON payloads
- Custom sender name
- Custom recipient email
- Custom message content
- Environment variable support using dotenv
- Event-driven email notification using EventEmitter
- Clone the repository
git clone <repository-url>
cd <project-folder>- Install dependencies
npm install- Create a
pass.envfile in the project root
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_google_app_password- Generate a Google App Password
- Open your Google Account
- Go to Security
- Enable 2-Step Verification
- Open App Passwords
- Generate an App Password
- Copy the generated password into
pass.env
node index.jsThe server starts on:
http://localhost:5000
Send a POST request using Postman or Thunder Client.
{
"from": "Abhinav",
"to": "receiver@example.com",
"message": "Hello from Node.js"
}data sent
- Node.js
- Nodemailer
- EventEmitter
- dotenv
- HTTP Module
- File System (fs)