简体   繁体   English

Nodemailer(Node.js)中的无效登录详细信息

[英]Invalid login details in Nodemailer (Node.js)

Been trying to implement a simple mail script using nodemailer in node.js . 一直在尝试使用node.js中的 nodemailer实现一个简单的邮件脚本。 This implementation is based on the Gmail API and I used this link as reference. 此实现基于Gmail API ,我使用此链接作为参考。 Now I am facing the below error 现在我面临以下错误

{ [Error: Invalid login]

code: 'EAUTH', response: '535-5.7.8 Username and Password not accepted. 代码:“ EAUTH”,响应:“ 535-5.7.8”,不接受用户名和密码。 Learn more at\\n535 5.7.8 https://support.google.com/mail/answer/14257 qe3sm505011pbc.73 - gsmtp', responseCode: 535 } 了解更多信息, 参见\\ n535 5.7.8 https://support.google.com/mail/answer/14257 qe3sm505011pbc.73-gsmtp',响应代码:535}

And the fallowing is the code that I used 休假是我使用的代码

var nodemailer = require('nodemailer');
var generator = require('xoauth2').createXOAuth2Generator({
    user: 'bharathvijay38',
    clientId: '***************',
    clientSecret: '***************',
    refreshToken: '***************',
    accessToken: '***************'
});

var transporter = nodemailer.createTransport({
    service: 'Gmail',
    auth: {
        user: 'xxxxx@xxxxx.xxx',
        pass: '************',
        xoauth2: generator
    }
});

transporter.sendMail({
    from: 'xxxxx@xxxxx.xxx',
    to: 'xxxxx@xxxxx.xxx',
    subject: 'hello!',
    text: 'Hello there !'
    }, function(error, info){
    if(error) {
        return console.log(error);
    }

    console.log("Message sent: "+info);
});

I am new to node.js and server side scripting. 我是node.js和服务器端脚本的新手。 So please kindly help me out 所以请帮我

Why do you need the xoauth2 options? 为什么需要xoauth2选项?

According to Nodemailer 根据Nodemailer

This is the basic usage 这是基本用法

var transporter = nodemailer.createTransport({
    service: 'Gmail',
    auth: {
        user: 'gmail.user@gmail.com',
        pass: 'userpass'
    }
});

Where the user is, your Gmail username and the password is, your Gmail password. 用户所在的位置是您的Gmail用户名,密码是您的Gmail密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM