intro-to-python icon indicating copy to clipboard operation
intro-to-python copied to clipboard

Sendgrid API Issues

Open s2t2 opened this issue 4 years ago • 6 comments

Students are having various issues with getting a working Sendgrid API Key. Posting possible solutions here.

s2t2 avatar Jun 18 '20 21:06 s2t2

From a student:

For those having "email forbidden" issues, are you using the same email that you used for your sendgrid account? I was having a similar issue for another project and that solved it

s2t2 avatar Jun 18 '20 21:06 s2t2

Some see "your account is temporarily under review"s under-review

s2t2 avatar Jun 18 '20 21:06 s2t2

Another student shared the email message from sendgrid that provides additional instructions:

Screenshot 2020-06-18 17 39 20

We can probably use the "single sender" approach.

EDIT, yes another student verifies this

I had to do the single sender verification on SendGrid in order to use my own API key.

UPDATE: another student says one way to do the verification process is through the settings menu:

Screenshot 2020-06-18 17 41 41

s2t2 avatar Jun 18 '20 21:06 s2t2

I have verified it is working. Need to setup single sender verification first. Then the following code should work. Also note the key with mail only didn't work. Full access API Key works. Would need to figure out the exact permissions needed to send an email.

# adapted from: 
# ... https://github.com/sendgrid/sendgrid-python/blob/main/USAGE.md
# ... https://github.com/sendgrid/sendgrid-python#with-mail-helper-class

from sendgrid import SendGridAPIClient

sg = SendGridAPIClient(api_key=API_KEY)

from sendgrid.helpers.mail import Email, To, Content, Mail

from_email = Email("[email protected]") # NEEDS TO MATCH VERIFIED SINGLE SENDER
to_email = To("[email protected]")
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "and easy to do anywhere, even with Python")

mail = Mail(from_email, to_email, subject, content)

response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)

Need to also verify templates are still working: https://github.com/sendgrid/sendgrid-python/blob/main/use_cases/transactional_templates.md

s2t2 avatar Feb 08 '21 15:02 s2t2

Some students are seeing that SendGrid has disabled / suspended their account:

  • Some say it happened after they accidentally pushed their API Keys to GitHub.
  • Some say it happened automatically.

image

Resolution Steps:

  • Some students reported that following up with SendGrid Support resolved the issue. Specifically mentioning they are a student.

s2t2 avatar Jun 18 '21 02:06 s2t2

Sendgrid keeps causing unnecessary issues for students.

Some students had their credentials revoked due to lack of use (even though we are actively using the credentials within the span of a single semester). This is a really dumb and investor deceptive practice on the part of Sendgrid that results in an artificially inflated number of accounts. I've emailed them about this and they refuse to fix the policy.

Other students have reached the max allowable emails limit:

The problem was that I went over the daily(or monthly?) limit of emails for a free sendgrid account. ... I got the issue fixed by using my groupmate's sendgrid credentials.

s2t2 avatar May 06 '22 16:05 s2t2

Using mailgun now

s2t2 avatar Nov 02 '23 05:11 s2t2