This is a sample API for sending emails using Node.js, Express, and Nodemailer.
- Clone the repository:
git clone https://github.com/juanmaescudero/api-mails- Navigate to the project directory:
cd api-mails- Install dependencies:
npm installCreate a .env file in the root of your project and set the following variables:
MAIL_USER=YOUR_EMAIL
MAIL_PASS=YOUR_PASS
MAIL_HOST=YOUR_SMTP_HOST
MAIL_PORT=YOUR_PORTMake sure to replace YOUR_EMAIL, YOUR_PASS, YOUR_SMTP_HOST, and YOUR_PORT with your actual email credentials and SMTP server information.
POST /mails/register: Send an email using the following JSON format:
{
"name": "John Doe",
"email": "[email protected]",
"template": "USER_REGISTER"
}POST /mails/lostPassword: Send an email using the following JSON format:
{
"name": "John Doe",
"email": "[email protected]",
"template": "LOST_PASSWORD"
}Ensure to set the appropriate headers and provide the required JSON payload when making requests to the API.
Feel free to customize and extend the API based on your specific email sending needs.