Skip to content
siddharthakonakanchi edited this page Dec 5, 2017 · 1 revision

Nodemailer

  1. Description
  2. Installation
  3. API calls using package
  4. Code Snippet
  5. Database Insertion
  6. Reference

Nodemailer

Description

Nodemailer is a module for Node.js applications to allow easy as cake email sending.

npm install uuid

Usage in our project

In order to generate a mail with subject line , body and send the forgt password link that contains token of the UUID generated random value

API Calls using package

The email is sent from

/users/forgot A mail from noreplygatormeetup@gmail.com is being sent to the user inorder to reset

Code Snippet

/users/forget

                     nodemailer.createTestAccount((err, account) => {
                        // create reusable transporter object using the default SMTP transport
                        let transporter = nodemailer.createTransport({
                            service: 'gmail',
                            auth: {
                                user: "noreplygatormeetup@gmail.com", // generated ethereal user
                                pass: "gatormeetup"  // generated ethereal password
                            }
                        });

                        // setup email data with unicode symbols
                        const token = uuidv4();
                        console.log(token);
                        let mailOptions = {
                            from: '"Forgot Password" <contact@gatormeetup.com>', // sender address
                            to: email, // list of receivers
                            subject: 'Hello ✔', // Subject line
                            html: user.name + '<br>' +
                                '<a href="' + SERVER_URL + 'users/reset/' + token + '">Click here to reset password</a>'

Database Insertion

No data base operations

Reference

More information can be obtained from https://nodemailer.com/about/

Clone this wiki locally