Nodemailer错误无法修复 [英] Nodemailer Error Can't Fix
问题描述
我有一个非常简单的应用程序,只是开始弄脏nodemailer。当我运行应用程序时,模块本身会出错。
I have a very simple application, just starting to get my hands dirty with nodemailer. When I run the app I get errors in the module itself.
app.js:
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport('smtps://me%40gmail.com:supersecretpw@smtp.gmail.com');
var mailOptions = {
from: '"Me" <me@gmail.com>', // sender address
to: 'him@him.com, her@her.com', // list of receivers
subject: 'Hello dude', // Subject line
text: 'Test email with text', // plaintext body
html: "Testing 1..2..7" // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
我收到此错误:
C:\Users\Andrew\desktop\messy4\node_modules\nodemailer\lib\mailer\index.js:31
compile: [(...args) => this._convertDataImages(...args)],
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\Andrew\desktop\messy4\node_modules\nodemailer\lib\nodemailer.js:3:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
真的不确定这里发生了什么。
Really not sure what's happenning here.
推荐答案
需要Node.js版本6+。使用以下命令检查您的节点版本:
Node.js version 6+ is required. Check your Node version with the following command:
node --version
如果您不是至少6岁以上,那么您必须升级。
If you are not at least 6+ then you must upgrade.
您可能会收到另一条错误消息,指示您登录您的帐户。在这种情况下,请转到您的电子邮件收件箱,您会看到来自Google的消息,其中包含指向设置不太安全的应用权限的页面的链接。
You may receive another error message instructing you to login to your account. In that case, go to your email inbox and you will see a message from Google with a link to a page for setting up less secure app permissions.
这篇关于Nodemailer错误无法修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!