javascript - 发件人地址与已验证的发件人身份不匹配
问题描述
作为所有者,我已经在其中验证了我的 gmail sendgrid
,当我使用所有者邮件帐户发送消息时它已经发送,但是当我尝试以具有不同邮件帐户的客户身份发送邮件时,然后向我显示如下错误:这意味着客户还需要使用 sendGrid 验证他们的邮件帐户吗?
{
errors: [
{
message: 'The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements',
field: 'from',
help: null
}
]
}
我不知道为什么。
我已经尝试过这样的代码:
const sgMail = require("@sendgrid/mail");
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
exports.contactForm = (req, res) => {
const { email, name, message } = req.body;
const emailData = {
to: process.env.EMAIL_TO,
from: email,
subject: `Contact form - ${process.env.APP_NAME}`,
text: `Email received from contact from \n Sender name: ${name} \n Sender email: ${email} \n Sender message: ${message}`,
html: `
<h4>Email received from contact form:</h4>
<p>Sender name: ${name}</p>
<p>Sender email: ${email}</p>
<p>Sender message: ${message}</p>
<hr />
<p>This email may contain sensetive information</p>
`,
};
sgMail
.send(emailData)
.then(() => {
console.log("Message sent");
})
.catch((error) => {
console.log(error.response.body);
});
};
任何建议请。
解决方案
Sendgrid(与其他批量电子邮件供应商一起)要求您发送每封电子邮件消息来自:一个众所周知的地址。您不能通过 Sendgrid 发送邮件,因此它看起来像是来自任意未经验证的电子邮件帐户。
为什么不?垃圾邮件。
像 Sendgrid 这样的公司为了防止他们的客户使用他们的服务发送垃圾邮件而费了很大的力气。如果他们让客户发送垃圾邮件,他们的服务器将被 gmail、outlook 和其他大型电子邮件提供商阻止,并出现在小型电子邮件提供商使用的反垃圾邮件阻止列表中。如果发生这种情况,很快就会破坏他们的业务。
因此,您在 Sendgrid 消息中声明为发件人地址的任何电子邮件帐户都必须经过验证。
推荐阅读
- android - Android View Binding -> CoordinatorLayout 不能转换为 DrawerLayout
- openedge - 浏览数据库文件
- amazon-web-services - 无论如何要告诉哪个云提供商当前的 k8s 集群正在运行?
- java - 构建 Gradle 本地依赖
- python - Gunicorn.service 无法读取 Python3.6 库
- html - 画布和 HTML 之间的文本对齐方式不同
- javascript - React Class 中的“TypeError:Class extends value undefined is not a constructor or null”问题
- android - 如何从主 Activity 更改片段的 textView 的大小?
- android - 几天后,Android WebView 崩溃并显示内存不足消息
- php - 使用 PHP 从非图片文件中删除元数据