const nodemailer = require("nodemailer");
let email = ""
let send_to = ""
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 587,
secure: false, // true for 465, false for other ports
auth: {
user: "", // generated ethereal user
pass: "", // generated ethereal password
},
});
var mailOptions = {
from: email,
to: send_to,
subject: 'Sending Email using Node.js',
text: '<h1>TEST DESH!!</h1>'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
npm install nodemailer
const transporter = nodemailer.createTransport({
host: 'smtp.ethereal.email',
port: 587,
auth: {
user: 'merritt92@ethereal.email',
pass: 'ZpKpEXzF1P1VFV7HPX'
}
});
const transporter = nodeMailer.createTransport({
host: process.env.SMTP_HOST,
port: 587,
secure: false,
auth: {
user: process.env.SMTP_MAIL,
pass: process.env.SMTP_PASSWORD,
},
});
const mailOptions = {
from: process.env.SMTP_MAIL,
to: emailUser.email,
subject: emailUser.subject,
text: emailUser.message,
};
await transporter.sendMail(mailOptions);
yarn add nodemailer
var smtpTransport = require('nodemailer-smtp-transport');
var transport = nodemailer.createTransport(smtpTransport({
service: 'gmail',
auth: {
user: 'myemail@gmail.com', // my mail
pass: 'mypassword'
}
}));