# Mailgun

## Step 1. Account Setup <a href="#setup" id="setup"></a>

* If you do not have an account with Mailgun yet, create an account here.
* Next you need to verify your domain. To create and verify a domain, please follow the Mailgun guide [here](https://documentation.mailgun.com/en/latest/user_manual.html#verifying-your-domain-1). Your account will have a sandbox domain initially, with which you can test emails with upto 5 [authorized recipients](https://help.mailgun.com/hc/en-us/articles/217531258-Authorized-Recipients).

## Step 2. Mailgun Integration in KDC <a href="#step-2-mailgun-integration-in-raven" id="step-2-mailgun-integration-in-raven"></a>

| Keys               | Details                                                                                                                                                                  |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `From Address`     | Your verified “From” email address                                                                                                                                       |
| `From Name`        | “From Name” of your emails. You can also pass this in the Send Event API. Check the Advanced section below.                                                              |
| `API Key`          | Your Mailgun Private API Key. To get your API key, check [here](https://help.mailgun.com/hc/en-us/articles/203380100-Where-Can-I-Find-My-API-Key-and-SMTP-Credentials-). |
| `Domain`           | Your verified email domain name. Check your domain name [here](https://login.mailgun.com/login/).                                                                        |
| `Reply to Address` | Reply email address. You can also pass this in the Send Event API. Check the Advanced section below.                                                                     |

## Step 3. Delivery Reports <a href="#dlr" id="dlr"></a>

Follow the steps to setup delivery reports:

1. On the KDC dashboard, once you successfully add the Mailgun Integration, you will see it in the “Live” tab. Go to the Live tab, and click on Mailgun Email. You will see a URL as **Status Webhook**, present in the integration. Copy this URL.
2. Log in to Mailgun and go to Sending > Webhooks.
3. Create a Webhook and Paste the Status Webhook URL copied in Step 1.

***

## 💫 Advanced <a href="#advanced" id="advanced"></a>

### **Send additional parameters to Mailgun** <a href="#params" id="params"></a>

KDC will send the fields present in the Email template to Mailgun by default. Additionally, you can send “`cc`”, “`bcc`”, “`From Name`”, “`Reply-to`” fields in the Send Event API. This will override the fields added in the Integration. Please check our Override doc here.

### **IP Whitelisting** <a href="#ip" id="ip"></a>

You can control access to Mailgun by specifying KDC’s IP address, or make sure KDC’s IP addresses are not blocked. Please follow the Mailgun guide [here](https://help.mailgun.com/hc/en-us/articles/360012244474-IP-Allowlist).

IPs: **`139.59.53.104`** | `64.227.148.154`

## 🔗 Links <a href="#links" id="links"></a>

* [Mailgun Website​](https://www.mailgun.com/)
* [Mailgun Documentation​](https://documentation.mailgun.com/en/latest/index.html)
* [Mailgun Console](https://login.mailgun.com/login/)


---

# 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.kdc.in/api/buzz/email/routes/mailgun.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.
