gpt4 book ai didi

express - unablle通过节点邮件程序发送电子邮件|无效的寄件者“emailid@gmail.com>”

转载 作者:行者123 更新时间:2023-12-04 16:28:18 24 4
gpt4 key购买 nike

我正在使用Express,Nodemailer和Express来测试通过gmail帐户发送电子邮件。但是由于某种原因,我无法发送它。此外,帐户的电子邮件和密码是100%正确的,仍然会收到此错误。错误不能说明问题所在。

另外,我已经“打开”了gmail设置,即降低了应用程序的设置。

我没有使用http://nodemailer.com/2-0-0-beta/using-oauth2/即使我使用此电子邮件ID登录到浏览器时也需要使用吗?

我确实需要在不使用浏览器的情况下进行开发,但是我希望之前能看到它的正常运行。

{[错误:无效的发件人“ ********** @ gmail.com>”]代码:“ EENVELOPE”,命令:“ API”}
/Users/jay/code/gmailSendEmail/app.js:43
res.json({yo:'error'});
^

var nodemailer = require('nodemailer');

var express = require('express');
var app = express();
var nodeMailer = require('nodemailer');
var transporter = nodemailer.createTransport();

console.log ( ' coming here 1');



var router = express.Router();
app.use('/sayHello', router);
router.post('/', handleSayHello); // handle the route at yourdomain.com/sayHello

function handleSayHello(req, res) {
// Not the movie transporter!
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: '****@gmail.com', // Your email id
pass: '*****' // Your password
}
});


var mailOptions = {
from: '*****@gmail.com>', // sender address
to: '*****@gmail.com', // list of receivers
subject: 'Email Example', // Subject line
text: 'Hello world ' //, // plaintext body
// html: '<b>Hello world ✔</b>' // You can choose to send an HTML body instead
};


console.log ( ' coming here 2');

transporter.sendMail(mailOptions, function(error, info){
console.log ( ' beginning emial sending ');
if(error){
console.log('got - error here');
console.log(error);
res.json({yo: 'error'});
}else{
console.log ( 'no error emial sending ')
console.log('Message sent: ' + info.response);
res.json({yo: info.response});
};
});

}

handleSayHello();

最佳答案

只需从中删除“>”

var mailOptions = {
from: '*****@gmail.com', // sender address
to: '*****@gmail.com', // list of receivers
subject: 'Email Example', // Subject line
text: 'Hello world ' //, // plaintext body
// html: '<b>Hello world ✔</b>' // You can choose to send an HTML body instead
};

关于express - unablle通过节点邮件程序发送电子邮件|无效的寄件者“emailid@gmail.com>”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39775592/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com