我正在尝试使用 nodemailer 从我的服务器发送电子邮件。不幸的是,由于这个错误,我一直无法对其进行测试:
D:\Full Stack\Node\NodeLoginJWT\functions\password.js:58
'This token is valid only within two minutes.'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected string
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Full Stack\Node\NodeLoginJWT\routes.js:9:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
[nodemon] app crashed - waiting for file changes before starting...
这是导致错误的代码块:
const transporter = nodeMailer.createTransport(`smtps://${config.email}:${config.password}@smtp.gmail.com`);
const mailOptions = {
from: `"${conifg.name}" <${config.email}>`,
to: email,
subject: 'Reset Password',
html: `Hello ${user.name}`,
'Your account password token is ${random}'
'This token is valid only within two minutes.'
'Thanks,'
'Team. '
};
return transporter.sendMail(mailOptions);