Sendgrid

We use Sendgrid to send emails and track email activity in our products.

A number of our products include functionality to send custom emails directly to your users and customers. Whether that's a confirmation email for users who have signed up to your newsletter, emails to handle password resets, or emails for invoice and order management. But to take advantage of this integration, you first need to subscribe to Sendgrid's free email distribution service, and obtain an API key.

Create your Account & Get your API Key

To get started, go ahead and sign-up to Sendgrid. Once you have your account, log-in and browse to the 'API Keys' section under 'Settings'. We are going to use this section to create a API Key with restricted access to handle email distributions, and nothing more.

Provide 'Full Access' for 'Mail Send', but limit all other functionality for your API to 'No Access'.

And then last up, copy down your API key, as we will need this later.

Authenticate your Domain

Next, you will need to authenticate your domain for Sendgrid. To do this, find the 'Sender Authentication' setting under 'Settings'.

Depending on your domain provider, you may be able to get some specific configuration settings from Sendgrid, so check if your domain is included in the list of options. If you would like, you can also set up branded links from your domain, rather than using the sendgrid.net redirect service.

Next, you will want to add your domain address, for example 'djangomango.com'.

And then finally, you'll be able to grab a set of DNS records which you can add via your domain provider.

Configure your DjangoMango Product

You are now ready to configure Sendgrid's integration for your DjangoMango product. To do so, simply edit the 'prod.env' file in your project folder so that the email host password key matches the API key value you copied down earlier.

DJANGO_EMAIL_HOST=smtp.sendgrid.net
DJANGO_EMAIL_PORT=587
DJANGO_EMAIL_HOST_USER=apikey
DJANGO_EMAIL_HOST_PASSWORD=YOUR_API_KEY_HERE
DJANGO_EMAIL_USE_TLS=True
DJANGO_EMAIL_USE_SSL=False

And that's it! Next time you run your app in development, you will be able to leverage Sendgrid for email handling.

Last updated