This project's main functionality is to send emails through the lib nodemailer, the application has automatic deployment on Heroku performed through the GitHub Actions, with all sensitive data protected in GitHub Secrets.
Clone the project
git clone https://github.com/BrunoSGomes/nodejs-mailer.gitEnter the project directory
cd nodejs-mailerInstall the dependencies
npm ciCreate an .env file (follow the .env.example)
# E-mail config
EMAIL_HOST= Your e-mail host
EMAIL_PORT= Your e-mail host port
EMAIL_SECURE= true or false if your e-mail has security (true most of cases)
EMAIL_USER= Your e-mail
EMAIL_PASSWORD= Your e-mail passwordStart the server
npm run start:devTest the application by sending a get request to localhost:3000
To run the code style check
npm run styleTo run the code style correction
npm run style:fixTo run the tests
npm run testFirst you need to create a repository on GitHub and a Node.js project on Heroku, after that, you will need to set the secrets that will be used in the GitHub Actions deployment workflow and also set the environment variables inside the Heroku project.
So first, with the GitHub repository created, let's set the following secrets
Name: ENV_VAR
Value:
# E-mail config
EMAIL_HOST= Your e-mail host
EMAIL_PORT= Your e-mail host port
EMAIL_SECURE= true or false if your e-mail has security (true most of cases)
EMAIL_USER= Your e-mail
EMAIL_PASSWORD= Your e-mail password
Name: HEROKU_API_KEY
Value: Your Heroku API Key
Name: HEROKU_APP_NAME
Value: Your Heroku application name
Name: HEROKU_EMAIL
Value: Your Heroku e-mailSecond, let's set the following environment variables in the Heroku project (same as local)
Name: EMAIL_HOST
Value: Your e-mail host
Name: EMAIL_PORT
Value: Your e-mail host port
Name: EMAIL_SECURE
Value: true or false if your e-mail has security (true most of cases)
Name: EMAIL_USER
Value: Your e-mail
Name: EMAIL_PASSWORD
Value: Your e-mail passwordNow just push the project to master on GitHub
POST /email/send| Parameter | Type | Description |
|---|---|---|
email |
string |
Mandatory. E-mail of the person |
name |
string |
Mandatory. Name of the person |
telephone |
string |
Mandatory. Telephone of the person |
message |
string |
Mandatory. A message |