Basic Node.js + Express server scaffold.
- Install dependencies: npm install
- Create env file: cp .env.example .env
npm run start
Server starts at http://localhost:3000 by default.
Open http://localhost:3000 in your browser to use the simple email form UI.
GET /health-> health check JSON response.GET /mail/verify-> verifies Nodemailer SMTP configuration and connectivity.GET /-> simple email sending interface.POST /send-email-> sends email using JSON body (receiverEmail,subject,body).POST /send-email-> sends an email using JSON payload.
Set these values in .env:
SMTP_SERVERSMTP_PORTEMAIL_USEREMAIL_PASSRECIEVER_EMAIL
For Gmail, use an App Password (not your normal account password).
POST /send-email
Request JSON:
receiverEmail(orto) stringsubjectstringbodystring
Example:
curl -X POST http://localhost:3000/send-email \
-H "Content-Type: application/json" \
-d '{
"receiverEmail": "receiver@example.com",
"subject": "Hello",
"body": "This is from Express + Nodemailer"
}'