Email Returns as Sent but not Receiving from sendgrid

…衆ロ難τιáo~ 提交于 2019-12-13 20:18:54

问题


I am trying to send email thru fire base cloud function. I am getting log that email is sent but I don't see any email. Below is the code and the logs. Where do I begin to troubleshoot?

'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))
}

I already enabled billing btw.

来源:https://stackoverflow.com/questions/49548276/email-returns-as-sent-but-not-receiving-from-sendgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!