【发布时间】:2022-01-19 14:07:15
【问题描述】:
我正在使用Firebase Functions 来托管SendGrid 实现,并且我无法使用SendGrid 中“单一发件人验证”列表中未包含的电子邮件发送电子邮件。
我在尝试从 randomemail@gmail.com 发送电子邮件时收到以下错误:
在 node_modules/@sendgrid/client/src/classes/client.js:146:29 在 processTicksAndRejections (internal/process/task_queues.js:95:5) 代码:403
我能够从我添加到Single Sender Verification list 中的SendGrid 的电子邮件中发送电子邮件。
这是我的firebase函数实现,请帮忙。我认为这个问题与域跨域或SandGrid 有关。
import * as functions from "firebase-functions";
const sgMail = require("@sendgrid/mail");
exports.emailMessage = functions.https.onCall((data) => {
sgMail.setApiKey("my key is here");
const msg = {
to: 'stanmozolevskiy@gmail.com', //here is one of the emails that I added to the Singlie Sender verification
from: data.sender, // only works with email from
subject: `${data.name} sent you email`,
text: data.message,
html: `<strong>${data.message}</strong>`,
}
sgMail
.send(msg)
.then(() => {
console.log('Email sent');
})
.catch((error:any) => {
console.error(error);
})
return{"status": "sucess", data: data};
});
【问题讨论】:
标签: node.js firebase google-cloud-functions sendgrid