[英]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.