我在firebase中有一个实时数据库。我的意图是在将事件添加到数据库的"paso1/"
一个分支时,会发送一封欢迎电子邮件。
我已使用 Firebase Cloud Functions 配置了所有内容,其他功能正常工作。发送此电子邮件的函数在 firebase 的“函数”部分中接收,并给出所有正确的消息。
但是,收件人的地址不会收到电子邮件。
我附上了我的函数的代码,因为我不知道它可能会失败。包括依赖项,在控制台中部署时一切正常,当执行在数据库中保存新字段的android应用程序时,它被正确注册并且函数返回消息“完成状态:ok”
const functions = require('firebase-functions');
const nodemailer = require("nodemailer");
const transport = nodemailer.createTransport({
service: "Gmail",
auth: {
user: "MY_EMAIL",
pass: "MY_EMAIL_PASSWORD"
}
})
exports.welcomeMail = functions.database.ref("paso1/{id}").onCreate((snap, context) => {
return sendWelcomeMail ()
});
// aux functions
function sendWelcomeMail() {
return transport.sendMail({
from: "Sergio <[email protected]>",
to: "[email protected]",
subject: "This is a subject",
text: "Hello my friend!"
})
.then(r=>r)
.catch(e=>e);
}
我尝试使用 "paso1/{id}" 或 "paso1/{uid}" 并进行了很多更改,但没有成功。
我感谢帮助获取邮件。
谢谢并恭祝安康。
最后,问题是我使用发送电子邮件帐户的主密码而不是 Google 生成的密码从第三方应用程序发送电子邮件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句