我使用express,nodemailer,&表示测试通过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();
答案 0 :(得分:9)
只需删除'&gt;'即可来自来自
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
};