答案在Google的消息中。
前往:https : //www.google.com/settings/security/lesssecureapps
将 访问不太安全的应用程序 设置为 启用
对于问题的第二部分,以及
我实际上只是在遵循nodemailer github页面上的步骤,所以我的代码中没有错误
我将引导您转到nodemailer github页面,以及以下代码:
var transporter = nodemailer.createTransport({service: 'Gmail',auth: { user: 'gmail.user@gmail.com', pass: 'userpass'}});它与您的代码略有不同,因为您具有:
nodemailer.createTransport("SMTP"。删除SMTP参数,它可以正常工作(刚刚测试)。另外,为什么要将其封装在http服务器中?以下作品:var nodemailer = require('nodemailer');var transporter = nodemailer.createTransport({ service: 'Gmail', auth: { user: 'xxx', pass: 'xxx' }});console.log('created');transporter.sendMail({from: 'xxx@gmail.com', to: 'xxx@gmail.com', subject: 'hello world!', text: 'hello world!'});


