在看了一些帖子后,我不知道为什么这个流星代码不能把邮件发送到我自己的邮箱地址。任何想法都是非常受欢迎的。
//server.main.js
import { Email } from 'meteor/email'
smtp = {
username: 'my@gmail.com',
password: 'pass',
server: 'smtp.gmail.com',
port: '465'
};
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server) + ':' + smtp.port;
//then inside a method call
Testimonies.insert(testamonyObj, function(err, res) {
if (!err) {
let add = 'myAdd@gmail.com'
let mess = 'alosh bel awee'
Email.send({ add, add, res, mess });
}
发布于 2021-04-12 00:35:47
嗯,您传递给Email.send
的options对象没有包含必要的字段,最明显的是to
字段,请参见https://docs.meteor.com/api/email.html#Email-send。当前对象只包含三个字段add
、res
和mess
,它们都不是send
函数可以识别的有效字段名。
试试这个:
Email.send({
to: add,
from: add,
subject: res,
text: mess
});
发布于 2021-04-11 16:26:30
乍一看,您的代码看起来很好。您需要在您的gmail帐户中允许安全性较低的应用程序。
你可以在这里阅读更多信息:https://support.google.com/accounts/answer/6010255?hl=en
https://stackoverflow.com/questions/67042822
复制相似问题