Sending mail with nodemailer to [email protected] address

let transporter = nodemailer.createTransport({
    service: '?',
    auth: {
        user: '[email protected]',
        pass: 'passHere'
    }
});

This is the code I’m using.

Earlier, I was sending the emails to a Gmail address, so “service” was “gmail” and it was working perfectly.

For an address like “[email protected]” what should I pass as “service”?

Answer

You can use SMTP API, you should use host(hostname or IP address to connect) instead of service like this:

nodemailer.createTransport({
  host: "smtp.example.com",  //<= add smtp server here
  port: 587, //add port
  secure: false, // upgrade later with STARTTLS
  debug: true,
  auth: {
    user: "username",
    pass: "password"
  }
});

For more details check here.