Sending email via Node.js using nodemailer is not working

后端 未结 9 1846
悲&欢浪女
悲&欢浪女 2020-11-29 20:15

I\'ve set up a basic NodeJS server (using the nodemailer module) locally (http://localhost:8080) just so that I can test whether the server can actually send ou

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 20:55

    For debugging purpose it is handy to implement a callback function (they never do on the nodemailer github page) which shows the error message (if there is one).

    transporter.sendMail({
        from: from,
        to: to,
        subject: subject,
        html: text
    }, function(err){
        if(err)
            console.log(err);
    })
    

    It helped me solve my problem... Turns out newer versions are not working properly:

    "Looks like nodemailer 1.0 has breaking changes so 0.7 must be used instead: http://www.nodemailer.com/

    Message posted on nodemailer as of 12/17/15:

    Do not upgrade Nodemailer from 0.7 or lower to 1.0 as there are breaking changes. You can continue to use the 0.7 branch as long as you like. See the documentation for 0.7 here."

    I found this answer here

提交回复
热议问题