Implementation of sending notification email with Nodemailer.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Software you need to install:-
- Visual Studio Code at Visual Studio Code
- or you can choose any Code Editor to your liking
- Node.js at Node.org
// Visual Studio Code Installation
Go to Visual Studio Code link above and choose download according to your machine type (choose the **stable** version):-
- Window, go for Windows Installer
- MacOS, go for MacOS Installer
- Linux, go for Linux Installer
// Node.js Installation
Go to Node.org link above and choose your machine type (Please choose the **LTS download version** instead of the Current version):-
- Window, go for Windows Installer
- MacOS, go for MacOS Installer
Please follow the step below to get the system running
- After download or git repo the Project file. Place your Project folder anywhere in your system (doesn't matter where actually)
- Open your Code Editor (Visual Studio Code or any other code editor)
- Go to your Terminal in Visual Studio Code or open CMD - Command Prompt, manuver to where your Project folder located and do the following installation:- (make sure you already inside your Project folder. Eg: C:\parentFolder\ProjectFolder) in order to get the final version running properly
- Install all dependencies required (as stated in package.json)
in your Terminal or CMD, it's gonna look like this:-
C:\sendMail\final\>npm install
- Once installation finishes with no errors. Then start the project:-
C:\sendMail\final\>npm start
- This project contain 2 main folders:-
- starter (contain starter codes and files needed)
- final (contain a complete working web app - finished code)
- This project aims to teach you how to implement a sending of email notification with Nodemailer.
- This project will not cover the part of designing and implementing or coding of the UI.
- create a starter folder
- npm
init
- install dependencies
- nodemon
- express
- dotenv
- nodemailer
- create & setup
index.js
- create & setup home routes
- create & setup
GET
home route- create a function to handle render of HOME page
- render HOME page
- create & setup
POST
home route- setup errorMessage handler
- create & setup send notification email
- setup Gmail API at Google Console API
- get
client id
- get
client secret
- get
- setup callback connection at OAuth 2.0 Playground
- in Step 1: Select & suthorize APIs, input
scope
tohttps://mail.google.com/
andclick
buttonAuthorize APIs
- in *Step 2: Exchange authorization code for tokens *,
set
orcheck
auto-refresh
token totrue
- in Step 1: Select & suthorize APIs, input
- OPTIONAL setup dedicated or other email extension other than gmail (Eg: .com/ .net/ .io/ etc)
- setup Gmail API at Google Console API
- re-render HOME page
- create & setup
No additional support on how to deploy on live system for this project.
These are some of the online sources which I learnt from. You may do so as well.