535 Incorrect authentication error with nodemailer

♀尐吖头ヾ 提交于 2020-04-11 05:43:30

问题


Nodemailer is working and sending emails with these settings on localhost but these are not working on live server.Why it is happening? It always throw an error of incorrect authorization. I tried many solution but still i'm stuck with this issue. Where i'm doing mistake? Can anyone figure out this?

Error:

{ Error: Invalid login: 535 Incorrect authentication data
    at SMTPConnection._formatError (/home/testing_node/public_html/testing_node/node_modules/nodemailer/lib/smtp-connection/index.js:784:19)
    at SMTPConnection._actionAUTHComplete (/home/testing_node/public_html/testing_node/node_modules/nodemailer/lib/smtp-connection/index.js:1523:34)
    at SMTPConnection._responseActions.push.str (/home/testing_node/public_html/testing_node/node_modules/nodemailer/lib/smtp-connection/index.js:550:26)
    at SMTPConnection._processResponse (/home/testing_node/public_html/testing_node/node_modules/nodemailer/lib/smtp-connection/index.js:942:20)
    at SMTPConnection._onData (/home/testing_node/public_html/testing_node/node_modules/nodemailer/lib/smtp-connection/index.js:749:14)
    at TLSSocket.SMTPConnection._onSocketData.chunk (/home/testing_node/public_html/testing_node/node_modules/nodemailer/lib/smtp-connection/index.js:195:44)
    at TLSSocket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at TLSSocket.Readable.push (_stream_readable.js:219:10)
    at TLSWrap.onread (net.js:635:20)
  code: 'EAUTH',
  response: '535 Incorrect authentication data',
  responseCode: 535,
  command: 'AUTH PLAIN' }

My code:

exports.sendNodeMail = function (email) {
    var transporter = nodemailer.createTransport({
        name: 'www.domain.com',
        host: 'box****.bluehost.com',
        port: 465,
        secure: false,
        auth: {
            user: 'noreply@domain.com',
            pass: 'password'
        },
        tls: {
            rejectUnauthorized: false
        }

    });

    const mailOptions = {
        from: 'noreply@domain.com',
        to: email,
        subject: 'Hello',
        html: 'Hello World'
    };
    return transporter.sendMail(mailOptions, function (err, info) {
        if (err)
            console.log(err);
        else
            console.log(info);
    });
};

回答1:


You should set your secure field to true for 465 port and false for all other ports. Also your name and host should be 'mail.someDomaine.com' but you can confirm that with you email provider.

Also, make sure the user and password are correct.



来源:https://stackoverflow.com/questions/59723690/535-incorrect-authentication-error-with-nodemailer

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