# Sendgrid

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](https://sendgrid.com/). 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.

![](/files/azjToP6ejNUxpdxwcQ0L)

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

![](/files/0sltowae8X6YOVpqmzmI)

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

![](/files/Kmv7wyrSkIWoRcqHP3QP)

### Authenticate your Domain

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

![](/files/JcYwGVsAXf7aUigpEttM)

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.

![](/files/l7eyzYhSl4eUTVbHrMgK)

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

![](/files/oZRqjznkwjXNwh8ytoY2)

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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.djangomango.com/integration-guides/sendgrid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
