微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么我们发送给 sendgrid SMTP 的电子邮件会收到此“无效的 SMTPAPI 标头”错误?

如何解决为什么我们发送给 sendgrid SMTP 的电子邮件会收到此“无效的 SMTPAPI 标头”错误?

我们使用 Spring org.springframework.mail.javamail.JavaMailSenderImpl 类将普通电子邮件消息从 Java Web 应用程序发送到 smtp.sendgrid.net 上的 sendgrid SMTP 服务器。我们不会向这些电子邮件添加任何 sendgrid 标头。

大量邮件因以下邮件而被退回:

Committee

虽然我们没有添加 sendgrid 标头,但如果我查看退回邮件内容,我会看到这些标头:

c = Committee.objects.prefetch_related('article_set')

幸运的是,JavaMailSenderImpl 类有一个调试属性,您可以将其设置为

Subject: Invalid SMTPAPI Header
SendGrid Support <support@sendgrid.com>
Fri 11/6/2020 11:27 AM
A message was received from this address by our systems that had errors in the SMTPAPI header,and cannot be processed due to the following:

  - error parsing xsmtpapi header

If you require assistance in working with the SendGrid API,please contact us at support@sendgrid.com

如果我启用它,我可以看到我的应用程序与 SendGrid SMTP 服务器的通信的转储,并且我可以看到我没有添加任何 X-SMTPAPI 标头。日志如下所示:

X-SMTPAPI-V3: {"from":{"name":"Error Messages MailBox","email":"developmentteam@example.com"},"display_to":"Exception MailBox \u003cexceptionmailBox@example.com\u003e","display_from":"Error Messages MailBox \u003cdevelopmentteam@example.com\u003e","subject":"[Staging:public] Expression has thrown an unchecked exception; see the cause exception.","personalizations":[{"to":[{"email":"exceptionmailBox@example.com"}]}],"reply_to":{"name":"Error Messages MailBox","email":"developmentteam@example.com"}}

X-SMTPAPI-V3-CONVERSION: 1

由于我们没有添加这些标头,我假设它们是由 smtp.sendgrid.net 添加的,然后它会根据这些相同的标头来退回邮件(?)

我在 2 个月前向 sendgrid 提交了一张支持票,但遇到了一堆未答复的问题。 (此外,如果您在这里遇到同样的问题,请不要理会 support@sendgrid.com 电子邮件;它回复了一封电子邮件,大喊要在他们的支持网站上寻求帮助。我也在 2 个月前提请了他们的注意.)

有没有人知道我们原始邮件中的哪些内容可能触发了错误的 SMTPAPI 标头的生成,以及哪些内容无效?文档不是很好,特别是对于我们不直接使用 SMTPAPI 的人。这些 API 调用是否有任何验证工具?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。