简体   繁体   English

Sendgrid 返回 202 但不发送电子邮件

[英]Sendgrid returns 202 but doesn't send email

I'm trying to get the basic "hello world" of sendgrid working, but have so far been unsuccessful.我试图让 sendgrid 的基本“hello world”工作,但到目前为止还没有成功。 The response returns code 202, suggesting that it will send the email, but the email never sends out.响应返回代码 202,表明它将发送电子邮件,但电子邮件从未发送出去。 Does anyone know what's going on?有谁知道发生了什么事?

import sendgrid

sg = sendgrid.SendGridAPIClient(apikey='**my-api-key**')
data = {
  "personalizations": [
    {
      "to": [
        {
          "email": "me@gmail.com"
        }
      ],
      "subject": "Hello World from the SendGrid Python Library!"
    }
  ],
  "from": {
    "email": "me@gmail.com"
  },
  "content": [
    {
      "type": "text/plain",
      "value": "Hello, Email!"
    }
  ]
}
response = sg.client.mail.send.post(request_body=data)
print(response.status_code)

I just had this issue: I created an account with SendGrid and tried to get the basic example working, the API would return a 202 response, but the email was never sent, and the SendGrid web UI's activity feed showed no activity.我刚刚遇到了这个问题:我使用 SendGrid 创建了一个帐户并尝试使基本示例正常工作,API 将返回202响应,但从未发送过电子邮件,并且SendGrid Web UI 的活动提要没有显示任何活动。

I submitted a SendGrid support ticket and ~8 hours later received a response saying that they had disabled my account's ability to send emails:提交了 SendGrid 支持票,大约 8 小时后收到回复说他们禁用了我的帐户发送电子邮件的能力:

Hello,你好,

Thanks for contacting SendGrid Support!感谢您联系 SendGrid 支持!

It looks like your account has been closed by our compliance team and this is the cause of the issue.您的帐户似乎已被我们的合规团队关闭,这就是问题的原因。

To reactivate we'd like to know a little more about the email you'll be sending through SendGrid.要重新激活,我们想了解更多有关您将通过 SendGrid 发送的电子邮件的信息。 Please elaborate on the following:请详细说明以下内容:

  1. The nature of your business, the services you provide, and your potential customer base您的业​​务性质、您提供的服务以及您的潜在客户群

  2. Your sending frequency and volume您的发送频率和数量

  3. How you collect your recipient addresses (link to opt in page, or sign up process)您如何收集收件人地址(选择加入页面的链接或注册过程)

  4. How you will allow your recipients to opt out of your emails (whether you plan to use SendGrid's one-click unsubscribe feature, or if you have your own method)您将如何允许收件人选择退出您的电子邮件(无论您打算使用 SendGrid 的一键退订功能,还是您有自己的方法)

  5. The types of messages you will be sending (transactional or marketing)您将发送的消息类型(交易或营销)

Please reply at your earliest convenience in order to continue the activation process.请在方便时尽早回复,以便继续激活过程。 Thanks for your cooperation!谢谢你的配合!


~15 hours after submitting my answers, I received a response saying my account had been "activated":提交答案约 15 小时后,我收到回复说我的帐户已“激活”:

Hi nathan.wailes,嗨 nathan.wailes,

Thanks for the additional information!感谢您的附加信息! Your SendGrid account has been activated, and can now be used to send email.您的 SendGrid 帐户已激活,现在可以用于发送电子邮件。 To get started, check out our Getting Started page.要开始使用,请查看我们的入门页面。

If you hit any snags while you're getting set up, you can find solutions to common problems and FAQS in our Knowledge Base .如果您在设置过程中遇到任何障碍,您可以在我们的知识库中找到常见问题的解决方案和常见问题解答。

Let me know if you have any more questions!如果您还有其他问题,请告诉我!

Best,最好的事物,

Stevin O.史蒂文O。

Associate Support Engineer助理支持工程师


When I then ran the basic example code with my email address set up as the recipient, the email showed up immediately in my Gmail inbox.当我运行基本示例代码并将我的电子邮件地址设置为收件人时,该电子邮件立即出现在我的 Gmail 收件箱中。

Debug this by going to the sendgrid api log here: https://app.sendgrid.com/email_activity通过转到此处的 sendgrid api 日志进行调试: https ://app.sendgrid.com/email_activity

In my case, it was a DMARC receiving domain block.就我而言,这是一个 DMARC 接收域块。

In case someone will come across this looking for an answer to a similar problem.万一有人会遇到这个寻找类似问题的答案。 I solved the same problem by confirming the domain with DNS records - after that everything worked like charm.我通过使用 DNS 记录确认域解决了同样的问题 - 之后一切都像魅力一样。

In Sendgrind: Setting > Senders Authentication > Domain Authentication在 Sendgrind 中:设置 > 发件人身份验证 > 域身份验证

I recently got the same issue.我最近遇到了同样的问题。 My e-mails were not sent without any reason, the response status was 202, e-mail activity was empty.我的电子邮件没有任何原因没有发送,响应状态为 202,电子邮件活动为空。 The possible solution is to add a company details and add an unsubscribe block to e-mail.可能的解决方案是添加公司详细信息并向电子邮件添加取消订阅块。 That worked for me.那对我有用。

I'm implementing a password reset feature and it's a little weird to have an unsubscribe block for this.我正在实施密码重置功能,为此设置取消订阅块有点奇怪。 I'll try to figure out what was the real reason of such silent suppression.我会试着弄清楚这种沉默压制的真正原因是什么。 Probably it's because I tried to send a draft debug e-mail several times which was looked like a spam.可能是因为我多次尝试发送看起来像垃圾邮件的草稿调试电子邮件。 Maybe SendGrid has some smart algorithms for detecting this.也许 SendGrid 有一些智能算法来检测这个。

I also had this issue.我也有这个问题。 I contacted sendgrid support however while waiting I changed the dummy data to real data I was calling sendgrid API with and then it started working.我联系了 sendgrid 支持,但是在等待时我将虚拟数据更改为我正在调用 sendgrid API 的真实数据,然后它开始工作。

in particular I changed the from email address to show my own domain.特别是我更改了电子邮件地址以显示我自己的域。

The same issue occurred when DNS is not verified and you are not using register email in from email .未验证 DNS 且您未使用from email注册电子邮件时,也会出现同样的问题。 Just change from email to register email.只需from email更改为注册电子邮件。

The 202 Accepted Status Code returned from SendGrid does not really indicate that the message has been successfully delivered to the recipients inbox.从 SendGrid 返回的 202 Accepted Status Code 并不真正表示邮件已成功传递到收件人收件箱。 It indicates that the message is valid and has been "Queued For Delivery".它表示消息有效并且已经“排队等待发送”。 Now, it is up to the receiving server to deliver this message to the recipients inbox, or to send it to spam, or simply drop the message.现在,由接收服务器将此邮件传送到收件人收件箱,或将其发送到垃圾邮件,或直接丢弃该邮件。

There are several reasons as to why messages that returns 202 Accepted Status code from SendGrid does not actually get delivered to the recipients inbox.关于为什么从 SendGrid 返回 202 Accepted Status 代码的邮件实际上没有传递到收件人收件箱的原因有很多。 For example:例如:

  1. Invalid email address : The email address may no longer be valid (example, when an employee stops working at some company, their email might be removed from the company's system removing the ability to receive any email).电子邮件地址无效:电子邮件地址可能不再有效(例如,当员工停止在某家公司工作时,他们的电子邮件可能会从公司的系统中删除,从而无法接收任何电子邮件)。
  2. Blocked Emails : If the sending IP or domain is blocked or if the recipients inbox provider has some filters set up such that some specific content of your email/campaign is considered spammy and thus gets automatically blocked.阻止的电子邮件:如果发送 IP 或域被阻止,或者收件人收件箱提供商设置了一些过滤器,以便您的电子邮件/活动的某些特定内容被视为垃圾邮件,因此会被自动阻止。

Another thing to note is that SendGrid may send the messages to spam/junk if the domain authentication has not been properly set up.另一件需要注意的事情是,如果域身份验证没有正确设置,SendGrid 可能会将邮件发送到垃圾邮件/垃圾邮件。 So make sure that your domain is properly authenticated.因此,请确保您的域已正确验证。

Here is the link to the documentation from SendGrid that explains these event in details.这是 SendGrid 文档的链接,详细解释了这些事件。 https://sendgrid.com/blog/delivered-bounced-blocked-and-deferred-emails-what-does-it-all-mean/ https://sendgrid.com/blog/delivered-bounced-blocked-and-deferred-emails-what-does-it-all-mean/

我遇到了同样的问题,并通过添加具有完全访问权限的新 api 密钥来解决它

For us, the problem was that the used dynamic template was not yet set to "active".对我们来说,问题在于使用的动态模板尚未设置为“活动”。 Unfortunately no error was shown about the in the API response or the log.不幸的是,API 响应或日志中没有显示关于 的错误。

Activating the email template solved this and emails are no longer dropped.激活电子邮件模板解决了这个问题,并且不再丢弃电子邮件。

I am able to send sendgrid email FROM company email address and TO Gmail address but not able to send email FROM company email address and TO company email address. I am able to send sendgrid email FROM company email address and TO Gmail address but not able to send email FROM company email address and TO company email address. I have got this message: Http Response Attributes{Status Code =202}.我收到此消息:Http 响应属性{状态代码 =202}。

For me the template was the issue.对我来说,模板是问题所在。 When using the template engine make sure to use {{variable}} instead of {{ variable }}.使用模板引擎时,请确保使用 {{variable}} 而不是 {{ variable }}。 Afterwards I received the emails as usual.之后我像往常一样收到了电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 SendGrid 和 blazor webassembly 发送电子邮件 - Can't send Email with SendGrid and blazor webassembly SendGrid Email 活动 API 无限制返回 BadRequest - SendGrid Email Activity API with no limit returns BadRequest 使用 SendGrid 和 Amazon work 发送电子邮件 email - Send emails using SendGrid and Amazon work email 使用 Sendgrid WebAPI 和 Cron 发送 email PHP - Send email with Sendgrid WebAPI and Cron PHP 我在通过 SendGrid 发送 Email 时在我的标题中添加了 In-Reply-To 和 References,但是它不起作用 - I added In-Reply-To and References in my headers while sending Email through SendGrid, however it doesn't work Sendgrid 电子邮件在部署到 Vercel 时不会发送 - Sendgrid emails won't send when deployed to Vercel 如何在 .NET 应用程序中使用 SendGrid V3 将 email 发送给多个收件人 - how to send an email using SendGrid V3 to multiple recipients, in a .NET app How to send HTML email with SendGrid Rest API using custom html file with Nodejs handlebars? - How to send HTML email with SendGrid Rest API using custom html file with Nodejs handlebars? 通过 nodeJs 中的 sendgrid 接收 email - receive email via sendgrid in nodeJs django sendgrid 发送唯一 arguments - django sendgrid send unique arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM