Sendgrid returns 202 but doesn't send email

独自空忆成欢 提交于 2019-11-27 17:50:31

问题


I'm trying to get the basic "hello world" of sendgrid working, but have so far been unsuccessful. The response returns code 202, suggesting that it will send the email, but the email never sends out. 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)

回答1:


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.

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:

Hello,

Thanks for contacting SendGrid Support!

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. 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)

  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":

Hi nathan.wailes,

Thanks for the additional information! Your SendGrid account has been activated, and can now be used to send email. 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.

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.




回答2:


Debug this by going to the sendgrid api log here: https://app.sendgrid.com/email_activity

In my case, it was a DMARC receiving domain block.




回答3:


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.

In Sendgrind: Setting > Senders Authentication > Domain Authentication




回答4:


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. 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.



来源:https://stackoverflow.com/questions/42214048/sendgrid-returns-202-but-doesnt-send-email

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!