Created
December 5, 2019 13:13
-
-
Save arkumish/d0e31b6dca3f33eaa2ba0135eba409bb to your computer and use it in GitHub Desktop.
Send mail through Nodemail in NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nodemailer = require("nodemailer"); //install this by "npm install nodemailer" | |
// Step 1 | |
let transporter = nodemailer.createTransport({ | |
service: 'gmail', | |
auth: { | |
user: 'your email id', // your gmail account | |
pass: 'password' // your gmail password | |
} | |
}); | |
// Step 2 | |
let mailOptions = { | |
from: 'your email-id', // email sender | |
to: 'sender emailid', // email receiver | |
subject: 'your email subject', | |
text: 'mail text' | |
}; | |
// Step 3 | |
transporter.sendMail(mailOptions, (err, data) => { | |
if (err) { | |
return console.log('Error occurs'); | |
} | |
return console.log('Email sent!!!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment