A simple backend service built with Express and Nodemailer to send emails. Designed to be lightweight, environment-configurable, and easily deployable (e.g., on Railway).
- Built with Node.js and Express
- Handles CORS and JSON requests
- Sends emails using Gmail SMTP via Nodemailer
.envsupport for secure config
backend/
βββ index.js # Main server file
βββ .env # Environment variables (not committed)
βββ package.json # NPM scripts and dependencies
βββ README.md # You're reading this
Create a .env file in the root directory:
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_email_app_password
PORT=3000
β οΈ Do not commit this file! Add.envto your.gitignore.
- Clone the repository:
git clone https://github.com/your-username/your-repo-name.git
cd backend- Install dependencies:
npm install- Start the server:
npm startOr use
npm run devif you're developing with live reload.
Make a POST request to:
POST http://localhost:3000/send
{
"to": "recipient@example.com",
"subject": "Test Email",
"text": "Hello from Erick's email backend!"
}| Command | Description |
|---|---|
npm start |
Start the server |
npm run dev |
Run with nodemon (live reload) |
npm run test |
Placeholder test script |
This a sample of what to expect when the route is hit.Please note it uses gmail smtp service.
Made with β€οΈ by Erick Olando