Skip to content

Instantly share code, notes, and snippets.

@wobsoriano
Last active August 17, 2019 13:18
Show Gist options
  • Save wobsoriano/a4ac291ed8599ec6c7bc0bbd872d4e8b to your computer and use it in GitHub Desktop.
Save wobsoriano/a4ac291ed8599ec6c7bc0bbd872d4e8b to your computer and use it in GitHub Desktop.
Send email using Nodemailer with Axigen credentials

Send email using Nodemailer with Axigen credentials

1. Install nodemailer package

npm install nodemailer --save

2. Copy example

const nodemailer = require("nodemailer");

async function run() {
  let transporter = nodemailer.createTransport({
    host: 10.10.120.68,
    port: 25,
    secure: false,
    auth: {
      user: sample@mirdc.dost.gov.ph // email generated by admin
      pass: password // password generated by admin
    },
    tls: {
      rejectUnauthorized: false
    }
  });

  let info = await transporter.sendMail({
      from: '"Fred Foo 👻" <foo@example.com>', // sender address
      to: "bar@example.com, baz@example.com", // 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: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
}

run().catch(console.error);

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment