Step 1

Please make sure that you have installed nodemailer.

Step 2

Please change the following in this script:

  • sender@example.com: the sender's email address.
  • recipient@example.com: the recipient's email address.
  • USERNAME: your SMTP2GO username.
  • PASSWORD: your SMTP2GO password.
var nodemailer = require("nodemailer");

var smtpTransport = nodemailer.createTransport({
  host: "mail.smtp2go.com",
  port: 2525, // 8025, 587 and 25 can also be used.
  auth: {
    user: "USERNAME",
    pass: "PASSWORD",
  },
});

smtpTransport.sendMail({
  from: "Sender Name ",
  to: "Recipient Name ",
  subject: "Your Subject",
  text: "It is a test message",
  html: "<p>It is a test message</p>"
},
  function (error, response) {
    if(error){
      console.log(error);
    } else {
      console.log("Message sent: " + response.message);
    }
  }
);

For more information about nodemail please see the official guides at: https://nodemailer.com/about/

Ready to get started?

Try SMTP2GO free for as long as you like:

Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.

Log In