16
loading...
This website collects cookies to deliver better user experience
$ npm install nodemailer
const nodemailer = require("nodemailer");
let testAccount = await nodemailer.createTestAccount()
let transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,//uses port 465 if secure is true.
secure: false,
auth: { user: testAccount.user, pass: testAccount.password },
});
let email = await transporter.sendMail({
from: '"Example User" <testAccount.user>', // sender address
to: "[email protected], [email protected]", // list of recipients
subject: "Hello World!", // Subject line
text: "My first Nodemailer email!", // plain text body
html: "<b>My first Nodemailer email!</b>", // html body
});
const main = () => {
let testAccount = await nodemailer.createTestAccount()
let transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,//uses port 465 if secure is true.
secure: false,
auth: { user: testAccount.user, pass: testAccount.password },
});
let email = await transporter.sendMail({
from: '"Example User" <[email protected]>', // sender address
to: "[email protected], [email protected]", // list of recipients
subject: "Hello World!", // Subject line
text: "My first Nodemailer email!", // plain text body
html: "<b>My first Nodemailer email!</b>", // html body
});
console.log("Email: "+email.messageId+" was sent.") //This prints to the console that the email has been sent.
}