首页 > 解决方案 > 发件人地址与已验证的发件人身份不匹配

问题描述

作为所有者,我已经在其中验证了我的 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);
    });
};

任何建议请。

标签: javascriptnode.jsemailsendgrid

解决方案


Sendgrid(与其他批量电子邮件供应商一起)要求您发送每封电子邮件消息来自:一个众所周知的地址。您不能通过 Sendgrid 发送邮件,因此它看起来像是来自任意未经验证的电子邮件帐户。

为什么不?垃圾邮件。

像 Sendgrid 这样的公司为了防止他们的客户使用他们的服务发送垃圾邮件而费了很大的力气。如果他们让客户发送垃圾邮件,他们的服务器将被 gmail、outlook 和其他大型电子邮件提供商阻止,并出现在小型电子邮件提供商使用的反垃圾邮件阻止列表中。如果发生这种情况,很快就会破坏他们的业务。

因此,您在 Sendgrid 消息中声明为发件人地址的任何电子邮件帐户都必须经过验证。


推荐阅读