Send mail using nodejs with TypeScript

Introduction

Send mail in node js using nodemailer library.We have provide send mail demo api like- send mail by nodemailer api.

What we have implemented in this project?

  1. Sending mail via emailId and password

Nodemailer features

  1. A single module with zero dependencies – code is easily auditable, as there are no dark corners
  2. Heavy focus on security, no-one likes RCE vulnerabilities
  3. Unicode support to use any characters, including emoji 💪
  4. Windows support – you can install it with npm on Windows just like any other module, there are no compiled dependencies. Use it hassle free from Azure or from your Windows box
  5. Use HTML content, as well as plain text alternative
  6. Add Attachments to messages
  7. Embedded image attachments for HTML content – your design does not get blocked
  8. Secure email delivery using TLS/STARTTLS
  9. Different transport methods in addition to the built-in SMTP support
  10. Sign messages with DKIM
  11. Custom Plugin support for manipulating messages
  12. Sane OAuth2 authentication
  13. Proxies for SMTP connections
  14. ES6 code – no more unintentional memory leaks, due to hoisted var’s
  15. Autogenerated email test accounts from Ethereal.email

Required dependencies:

Node is installed (v 16.16.0)

npm is installed (v 8.11.0)

mongodb is installed

Git is installed

Prerequisites

Express

Understanding of rest api

Idea for working in backend technology.

Create development.env to setup required environment variables

Go to the pre-start folder and env>development.env file directory

NODE_ENV=development

jwt_secret_key=""

MONGO_URI=""

Api code

Api path - src/controllers/customer/

Installing Dependencies

Express

Mongoose

Dotenv

Bcryptjs

nodemailer: npm install nodemailer

DB Setup

use mongodb so go to mongodb create the cluster and get the url from connection and add in .env file.
DB_URL = "****"

Server

PORT=3009

HOST=localhost

Setup Steps:

Install project dependency

npm install

local server

npm run start:dev

prod build

npm run build

prod build run

node dist/index.js

Send mail demo apis -

Send mail api using nodemailer

{{Your Ip}}/api/v1/mailer/senaMailByMailer