当有任何内容写入时,我正在尝试向我的电子邮件发送一封测试电子邮件/emails
但电子邮件永远不会发送,并且功能日志为空。
exports.sendTestEmail = functions.database.ref('/emails')
.onWrite(event => {
return sendTestEmail('[email protected] /cdn-cgi/l/email-protection');
})
// [END onWrite]
// Sends a welcome email to the given user.
function sendTestEmail(email) {
const mailOptions = {
from: `${APP_NAME} <[email protected] /cdn-cgi/l/email-protection>`,
to: email
};
// The user subscribed to the newsletter.
mailOptions.subject = `Welcome to ${APP_NAME}!`;
mailOptions.text = `Hey there! Welcome to ${APP_NAME}. I hope you will enjoy our service.`;
return mailTransport.sendMail(mailOptions).then(() => {
console.log('New welcome email sent to:', email);
});
}
Edit ***
上面的代码有效。我试图触发该功能emails
而正确的名字是email
.
使用 Firebase Cloud Functions 发送电子邮件的正确方法!
exports.sendTestEmail = functions.database.ref('/emails')
.onWrite(event => {
return sendTestEmail('[email protected] /cdn-cgi/l/email-protection');
})
// [END onWrite]
// Sends a welcome email to the given user.
function sendTestEmail(email) {
const mailOptions = {
from: `${APP_NAME} <[email protected] /cdn-cgi/l/email-protection>`,
to: email
};
// The user subscribed to the newsletter.
mailOptions.subject = `Welcome to ${APP_NAME}!`;
mailOptions.text = `Hey there! Welcome to ${APP_NAME}. I hope you will enjoy our service.`;
return mailTransport.sendMail(mailOptions).then(() => {
console.log('New welcome email sent to:', email);
});
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)