Sending emails with nodemailer

妖精的绣舞 提交于 2019-12-05 03:10:36

Try adding:

    tls: {
        rejectUnauthorized: false
    },

To your nodemailer options object.

After adding what @Richard Macarthy suggested, and looking up the new error I got back, I figured out that the from email in my mailOptions has to be the same as the email I'm using to send the emails from - which actually makes perfectly sense now.

In this case:

var mailOptions = {
    from: 'Olaf <support@companyname.dk>',
    to: 'john@test.dk',
    ...
var transporter = nodemailer.createTransport({<br>
host: 'hostSTMP',
secure: false, //disable SSL    
requireTLS: true, //Force TLS
    tls: {
        rejectUnauthorized: false
    },
    port: port, //Port of STMP service
    auth: {
      user: 'user@user.com',
      pass: 'password'
   }
});

rejectUnauthorized: If true, the server certificate is verified against the list of supplied CAs. An error event is emitted if verification fails; Default: true.

rejectUnauthorized: If false, you're saying "I don't care if I can't verify the server's identity."

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!