我正在尝试通过火力基础云功能发送电子邮件。我收到已发送电子邮件的日志,但我没有看到任何电子邮件。下面是代码和日志。我从哪里开始排除故障?
'use strict';
const functions = require('firebase-functions');
const nodemailer = require('nodemailer');
const SEND_GRID_API_KEY = functions.config().sendgrid.key
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(SEND_GRID_API_KEY);
// Your company name to include in the emails
// TODO: Change this to your app or company name to customize the email sent.
const APP_NAME = 'Asia Rubber';
// [START sendWelcomeEmail]
/**
* Sends a welcome email to new user.
*/
// [START onCreateTrigger]
exports.sendWelcomeEmail = functions.auth.user().onCreate((event) => {
// [END onCreateTrigger]
// [START eventAttributes]
const user = event.data; // The Firebase user.
const email = user.email; // The email of the user.
const displayName = user.displayName; // The display name of the user.
// [END eventAttributes]
return sendWelcomeEmail(email, displayName);
});
// [END sendWelcomeEmail]
// [END sendByeEmail]
// Sends a welcome email to the given user.
function sendWelcomeEmail(email, displayName) {
const msg = {
from: `${APP_NAME} <Welcome@rubber.asia>`,
to: email,
subject: 'Welcome to ${APP_NAME}!',
//custom templates
templateId: 'e3978a51-5343-4b3a-9128-8c4a493f265e'
};
return sgMail.send(msg)
.then( () => console.log('email sent'))
.catch(err => console.log(err))
}
我已经启用了计费顺便说一句。