This is a simple SMTP mailer service for sending emails using Node.js and Express.
- Features
- Prerequisites
- Getting Started
- Usage
- API Endpoints
- Docker Support
- Screenshots
- Contributing
- License
- Send emails via SMTP server
- Configurable via environment variables
- Node.js
- npm
- SMTP server credentials (host, port, username, password)
-
Clone the repository:
git clone https://github.com/yourusername/smtp-mailer.git cd smtp-mailer
-
Install the dependencies:
npm install
Configure the SMTP server and other settings by creating a .env file in the project root. You can copy the provided .env.example file and update it with your SMTP server credentials and other settings.
SMTP_HOST=your-smtp-host
SMTP_PORT=your-smtp-port
SMTP_USER=your-smtp-username
SMTP_PASS=your-smtp-password
Start the SMTP mailer service with the following command:
npm start
The service will listen on port 3000 by default, but you can customize it in your .env file.
-
POST /send-mail: Send an email. You should provide the email content and recipient information in the request body. Example Request:
{ "to": "recipient@example.com", "subject": "Your Subject", "text": "Your email content." }
Example Response:
{
"message": "Email sent successfully!"
}
You can also run this service in a Docker container. A Dockerfile is provided in the repository. Build the Docker image and run the container with your custom environment variables.
Example Docker commands:
docker run -itd -e DB_HOST=my-database-container -e DB_PORT=3306 -e DB_USER=admin -e DB_PASSWORD=Password1! -e SECRET_API_KEY=ad8fb3c8b78bee02ea05c05f64936cc9 -p 3000:3000 smtp-mailer
Feel free to contribute to this project. Fork the repository, make your changes, and submit a pull request.
Please replace placeholders like yourusername
, your-smtp-host
, and your-smtp-username
with your actual information. This README covers basic sections, and you can add more details or sections as needed for your project.