[Django]-Error when sending email through Sendgrid API

5👍

The issue originates from a breaking change introduced in sendgrid 6.0. The keyword argument for apikey has been removed and replaced with a positional argument.

To resolve with your example, remove apikey= from your arguments, and just pass the api_key as a positional argument.

    sg = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))

This can be a bit confusing when looking back at all previous examples as well as GitHub documentation, but this example on the official documentation does get it right.


Note: I do see that at the time of asking your question, you were indeed following the documentation I linked above correctly. There are a few issues opened where the documentation remained inaccurate for quite some time, but was resolved back in may.

Leave a comment