【问题标题】:Zoho mail says 535 Authentication Failed in Node JsZoho 邮件在 Node Js 中显示 535 Authentication Failed
【发布时间】:2019-06-02 10:10:45
【问题描述】:

我正在使用 Node Express 和 MongoDB 创建一个应用程序。用户创建成功后,想要发送给用户的邮件。我正在使用 zohomail,可以使用这些用户名和密码在线登录 zohomail。但是当我尝试发送邮件时,我收到了一个错误

  code: 'EAUTH',
  response: '535 Authentication Failed',
  responseCode: 535,
  command: 'AUTH PLAIN'

这是我的代码

helped snippet from

if (user) {
  var transporter = nodemailer.createTransport({
    host: 'smtp.zoho.com',
    port: 465,
    secure: true, // use SSL
    auth: {
      user: 'sample@sample.com',  //zoho username
      pass: 'password'  //zoho password## Heading ##
    }
  });

  var mailOptions = {
    from: 'sample@sample.com',
    to: req.body.email,
    subject: 'Created Successfully',
    html: '<h1>Hi ' + req.body.fname + ',</h1><p>You have successfully created.</p>'
  };

  transporter.sendMail(mailOptions, function(error, info) {
    if (error) {
      console.log(error);
    } else {
      res.status(200).send(setting.status("User created Successfully, Please Check your Mail"))
    }
  });
}

【问题讨论】:

    标签: node.js nodemailer zoho


    【解决方案1】:

    谢谢Nguyen Manh Tung

    正如评论中所说。

    我在 Zoho Mail 中启用了 2 因素身份验证 (2FA)。

    所以,我登录我的帐户 here 并转到两因素身份验证并获取应用程序特定密码。

    之后我在 Node Js 中使用了应用程序特定密码而不是 zoho mail 密码。

    if (user) {
      var transporter = nodemailer.createTransport({
        host: 'smtp.zoho.com',
        port: 465,
        secure: true, // use SSL
        auth: {
          user: 'sample@sample.com',  //zoho username
          pass: 'application specific password'  //Not zoho mail password because of 2FA enabled
        }
      });
    
      var mailOptions = {
        from: 'sample@sample.com',
        to: req.body.email,
        subject: 'Created Successfully',
        html: '<h1>Hi ' + req.body.fname + ',</h1><p>You have successfully created.</p>'
      };
    
      transporter.sendMail(mailOptions, function(error, info) {
        if (error) {
          console.log(error);
        } else {
          res.status(200).send(setting.status("User created Successfully, Please Check your Mail"))
        }
      });
    }
    

    【讨论】:

      【解决方案2】:

      1/ 检查您的密码。

      2/ 检查 2 因素身份验证

      您是否使用 Zoho 启用了 2 因素身份验证?

      如果您启用它,您需要创建应用程序专用密码。

      【讨论】:

      • 是的,我的密码没问题。 2FA 通过 Google Authenticator 启用。如何创建应用程序专用密码?
      【解决方案3】:

      如果您来自印度,请将 smtp.zoho.com 替换为 smtp.zoho.in,保持其他内容不变。示例如下:

      const transporter = nodemailer.createTransport({
        host: "smtp.zoho.in",
        port: 465,
        secure: true,
        auth: {
          user: process.env.ZOHO_EMAIL,
          pass: process.env.ZOHO_PASSWORD,
        },
      });
      

      【讨论】:

        猜你喜欢
        • 2018-01-01
        • 1970-01-01
        • 2021-12-10
        • 1970-01-01
        • 2015-09-28
        • 1970-01-01
        • 2022-07-18
        • 2019-04-28
        • 2021-07-30
        相关资源
        最近更新 更多