Skip to content

Latest commit

 

History

History
105 lines (71 loc) · 2.01 KB

File metadata and controls

105 lines (71 loc) · 2.01 KB

📬 Node.js Email Backend Service

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).


🚀 Features

  • Built with Node.js and Express
  • Handles CORS and JSON requests
  • Sends emails using Gmail SMTP via Nodemailer
  • .env support for secure config

📁 Project Structure

backend/
├── index.js           # Main server file
├── .env               # Environment variables (not committed)
├── package.json       # NPM scripts and dependencies
└── README.md          # You're reading this

⚙️ Environment Variables

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 .env to your .gitignore.


💻 Installation & Running Locally

  1. Clone the repository:
git clone https://github.com/your-username/your-repo-name.git
cd backend
  1. Install dependencies:
npm install
  1. Start the server:
npm start

Or use npm run dev if you're developing with live reload.


📫 Sending an Email

Make a POST request to:

POST http://localhost:3000/send

Request body (JSON):

{
  "to": "recipient@example.com",
  "subject": "Test Email",
  "text": "Hello from Erick's email backend!"
}

🧾 Scripts

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.

👤 Author

Made with ❤️ by Erick Olando