Code Monkey home page Code Monkey logo

brunosgomes / nodejs-mailer Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 132 KB

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.

License: MIT License

Shell 1.95% JavaScript 98.05%
babel-jest cicd ecmascript-modules eslint expressjs github-actions heroku jest nodejs nodemailer

nodejs-mailer's Introduction

Node.js Mailer ๐Ÿ“จ

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.

Running locally ๐Ÿ 

Clone the project

  git clone https://github.com/BrunoSGomes/nodejs-mailer.git

Enter the project directory

  cd nodejs-mailer

Install the dependencies

  npm ci

Create 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 password

Start the server

  npm run start:dev

Test the application by sending a get request to localhost:3000

Running tests and style checking ๐Ÿช„

To run the code style check

  npm run style

To run the code style correction

  npm run style:fix

To run the tests

  npm run test

Deploy ๐Ÿ“ฆ

First 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-mail

Second, 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 password

Now just push the project to master on GitHub

API Documentation ๐Ÿ“œ

Sends an email to the recipient defined in the .env

  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

nodejs-mailer's People

Contributors

brunosgomes avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.