javascript - 535使用nodemailer的错误身份验证错误

标签 javascript node.js smtp nodemailer bluehost

Nodemailer正在使用这些设置在localhost上运行并发送电子邮件,但这些在实时服务器上不起作用。为什么会这样?它总是会引发错误的授权错误。我尝试了许多解决方案,但仍然遇到这个问题。我在哪里做错了?有人能弄清楚吗?

错误:

{ 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' }



我的代码:

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);
    });
};

最佳答案

您应该将465端口的安全字段设置为true,而将所有其他端口的安全字段设置为false。另外,您的姓名和主持人应为“ mail.someDomaine.com”,但您可以与电子邮件提供商确认。

另外,请确保用户和密码正确。

关于javascript - 535使用nodemailer的错误身份验证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59723690/

相关文章:

node.js - Node 脚本 : Chaining commands with watchify

php - CodeIgniter SMTP 电子邮件消息 - 字符替换为等号

php - 无法使用 PHP 发送电子邮件

javascript - 在 Jquery 中导出百分比

javascript - 将原始字符串更改为字符串对象引用

javascript - 为什么node.js中的mysql多语句选项会增加SQL注入(inject)的范围?

php - SSL 连接错误 :140770FC

javascript - Backbone js : Not getting data from model while fetching data using rest api in collection

javascript - 如何根据其他数组更改原始数组

node.js - 通过迭代子 Node 添加值