简体   繁体   中英

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"?

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 .

If you add logger: true to the transporter will log all the server SMTP activity out in the console.

So to just add to the first answer, which I totally agree with:

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

Mailtrap wrote a little article about it that explains both debug and logger a little more: https://blog.mailtrap.io/sending-emails-with-nodemailer/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM