Skip to main content

Installation

To install Nodemailer in your Node.js project, follow these steps:

Step 1: Initialize Your Project​

First, make sure you have Node.js and npm installed. If not, you can download and install them from the official Node.js website.

  1. Create a new directory for your project (if you don't already have one):

    mkdir my-project
    cd my-project
  2. Initialize a new Node.js project:

    npm init -y

Step 2: Install Nodemailer​

You can install Nodemailer using npm. Run the following command in your project directory:

npm install nodemailer

This command will install Nodemailer and add it to your package.json file as a dependency.

Setp 3: How Import​

Two methods to import the package

  • In node & Express Js
const nodemailer=require('nodemailer')
  • In another ES6 method
import nodemailer from 'nodemailer'