Search code examples
javascriptnode.jsreactjsnodemailer

Sending mail with nodemailer to office@company.ro address


let transporter = nodemailer.createTransport({
    service: '?',
    auth: {
        user: 'office@company.ro',
        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 "office@company.ro" what should I pass as "service"?


Solution

  • 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.