Skip to content

Jedidiah-Solomon/Nodemailer-MailSender

Repository files navigation

NODEMAILER

Nodemailer is a module for Node.js applications to allow easy as cake email sending. The project got started back in 2010 when there was no sane option to send email messages, today it is the solution most Node.js users turn to by default.

Commands

npm install nodemailer npm install dotenv

const nodemailer = require("nodemailer");

const transporter = nodemailer.createTransport({
  host: "smtp.ethereal.email",
  port: 587,
  secure: false, // Use `true` for port 465, `false` for all other ports
  auth: {
    user: "[email protected]",
    pass: "jn7jnAPss4f63QBp6D",
  },
});

// async..await is not allowed in global scope, must use a wrapper
async function main() {
  // send mail with defined transport object
  const info = await transporter.sendMail({
    from: '"Maddison Foo Koch 👻" <[email protected]>', // sender address
    to: "[email protected], [email protected]", // list of receivers
    subject: "Hello ✔", // Subject line
    text: "Hello world?", // plain text body
    html: "<b>Hello world?</b>", // html body
  });

  console.log("Message sent: %s", info.messageId);
  // Message sent: <[email protected]>
}

main().catch(console.error);

Steps in Gmail

  1. Visit https://myaccount.google.com/ then to Security then to 2fa, enable 2fa

  2. Search for App passwords, the create one e.g Name: Nodemailer Jedybrown Ventures, password = dwxm naum ylkg cfgd

  3. Run node sendMail.js to send tthe mail to customers.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published