'535-5.7.8不接受用户名和密码。了解更多信息,请访问\ n535 5.7.8 https://support.google.com/mail/?p=BadCredentials x66sm1596680lff.64 - gsmtp'我该怎么办? 我正在尝试将电子邮件消息集成到我的应用程序中,即使在通过Gmail API激活并检索client_id和client_secret之后,它仍然无效。
let express = require('express')
let formidable = require('formidable');
let nodemailer = require('nodemailer');
let router = express.Router();
let app = express()
app.use(express.static('dist'));
app.use(express.static('public'));
app.use('/email', router);
router.get('/', handleSayHello);
function handleSayHello(req, res){
var transporter = nodemailer.createTransport({
service: "Gmail",
auth: {
XOAuth2: {
user: "mygmail@gmail.com",
clientId: "my-generated-OAuthId",
clientSecret: "my-generated-OAuthSecret",
}
}
})
var tex_t = `<h1 style = "text-align: center">Hello Joshua</h1>
<p>How are you doing today</p>
`;
var mailOptions = {
to : 'anotherUser@soso.com',
from: 'anotherDifferentUser',
subject: 'Email Example',
html: tex_t,
};
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
res.json({yo: 'error'});
}else{
console.log("Message sent: " + info.response);
res.json({yo: info.response});
};
});
}
app.set('port', (process.env.PORT || 3000));
app.listen(app.get("port"), ()=>{
console.log("App listening at ", app.get('port'));
})
答案 0 :(得分:0)