[英]SendGrid unable to send email, firebase functions. (code: 403)
我正在使用Firebase Functions
来托管SendGrid
实现,并且我无法使用SendGrid
中“单一发件人验证”列表中未包含的电子邮件发送电子邮件。
尝试从randomemail@gmail.com
发送 email 时出现以下错误:
在 node_modules/@sendgrid/client/src/classes/client.js:146:29 在 processTicksAndRejections (internal/process/task_queues.js:95:5) 代码:403
我可以从添加到SendGrid
中的单一发件人验证列表的电子邮件中发送电子邮件。
这是我的 firebase function 实现,请帮助。 我认为问题与域交叉起源或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};
});
尝试从 randomemail@gmail.com 发送 email 时出现(以下)错误:
...
我能够从添加到 SendGrid 中的单一发件人验证列表的电子邮件中发送电子邮件。
这是正常的,Sendgrid 只允许从经过验证的 email 发送的电子邮件,以避免潜在的恶意用户以他人的名义(即“在邮件中”)发送电子邮件。
请注意,如果您的发件人地址来自同一个 email 域,您可以进行域身份验证并避免注册域的每个 email 地址。
Sendgrid 只允许从经过验证的 email 发送的电子邮件,但您可以使用replyTo
属性来解决问题。
const msg = {
to: verifiedEmail,
from: verifiedEmail,
**replyTo: data.sender,**
subject: `${data.name} sent you email`,
text: data.message,
html: `<strong>${data.message}</strong>`,
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.