流星:发送电子邮件| AuthError:登录无效 - 535-5.7.8

flo*_*wen 5 email meteor

我已安装电子邮件包并尝试发送测试邮件,但它向我显示以下错误:AuthError:无效登录 - 535-5.7.8用户名和密码不被接受

我确信凭据是正确的,代码与以下内容相同:https://github.com/ideaq/meteor-email

/server/init.js

process.env.MAIL_URL="smtp://USERNAME%40gmail.com:PASSWORD@smtp.gmail.com:465/";
console.log(process.env.MAIL_URL);

Email.send({
    from: "from@gmail.com",
    to: "my-email@gmail.com",
    subject: "Meteor Can Send Emails via Gmail",
    text: "test"
});
Run Code Online (Sandbox Code Playgroud)

还尝试过:

// configure email later for validation and sending messages
smtp = {
    username: 'myusername@gmail.com',
    password: 'my-pw',
    server:   'smtp.gmail.com',
    port: 465
};

process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server) + ':' + smtp.port;
Run Code Online (Sandbox Code Playgroud)

我似乎无法找到有关此问题的任何其他信息或如何跟进它.谁能给我一个线索?

flo*_*wen 4

谢谢大家的建议!我通过实际打开两步验证、生成应用程序密码并使用它作为登录来修复它。奇怪的解决方案,但它有效!