SendGrid integration with python

Allwin Raju
3 min readDec 12, 2020

In this article, we shall see how to integrate SendGrid with python to send our emails.

What is SendGrid?

SendGrid is a cloud-based SMTP provider that allows you to send email without having to maintain email servers. SendGrid manages all of the technical details, from scaling the infrastructure to ISP outreach and reputation monitoring to whitelist services and real-time analytics.

Let us get started

First, let's go to the SendGrid website and create a free account. With the help of a free account, we can send up to 100 emails per day. This will be suitable for development purposes, but if you wish to send more than 100 emails per day, you have to upgrade your account.

1. Create an account

After entering the website, click on the start for free button and you will be redirected to the following page. Enter the email and password to create an account.

account creation page

2. Create an API key

After we have successfully created our account, the next step is to create an API key so that we can use it in our python code to communicate with our account. Go to this page and create a new API key.

API keys list

3. Email verification

The next thing we have to do is to verify our email which we will be using to send emails. We can verify our email in two ways, either by single sender verification or domain verification.

Click on this page to verify your email. Once it is done, we are good to go.

email verification

The code example

Let us create a simple program in python to send an email. First, we have to install the SendGrid Python library. You can easily install it using pip by running the following command in your terminal.

$ pip install sendgrid

Once the package is installed, we can send emails using SendGrid. I have added a python code example below.

You can also find all the steps here from their official page.

Conclusion

Hope this article is helpful. In addition to python, they also support other programming languages right out of the box. Feel free to use the one you are comfortable with. Happy coding!

--

--