---
title: Mailgun
description: >-
  Cloud based email service that helps developers send, track, and receive
  emails
breadcrumbs: Docs > Integrations > Mailgun
---

# Mailgun
Integration version2.0.0
## Overview{% #overview %}

Mailgun is an API-based email delivery platform that allows you to:

- Build and manage large-scale email marketing applications.
- Send and track transactional messages.
- Remove invalid email addresses from your list.
- Improve your deliverability and drive higher conversion rates.

Integrate with Datadog to collect email delivery and engagement metrics and logs to track the performance of your Mailgun services.

## Setup{% #setup %}

### Add and verify domain{% #add-and-verify-domain %}

1. Log in to your [Mailgun account](https://login.mailgun.com/login/).
1. In the sidebar on the left, click **Sending**. The menu expands. Select **Domains**.
1. Click **Add New Domain** at the top right.
1. Enter your Domain name and region and click **Add Domain**.
1. Verify your domain by following [the instructions in the Mailgun documentation](https://help.mailgun.com/hc/en-us/articles/360026833053).

### View Mailgun API key{% #view-mailgun-api-key %}

When you sign up for Mailgun, a primary account API key is created for you. This key allows you to perform all CRUD operations through our various API endpoints and for any of your sending domains.

1. Log in to your [Mailgun account](https://login.mailgun.com/login/).
1. Click your name on the top right, and open the dropdown.
1. Click **API Keys**.
1. Click the eye icon next to **Private API Key**.

### Enable metrics collection{% #enable-metrics-collection %}

1. Navigate to the configuration tab inside the Datadog [Mailgun integration tile](https://app.datadoghq.com/integrations/mailgun).
1. Enter your domain name and the region for your domain.
1. Paste in the API Key found in the steps above.
1. Optionally, add custom tags to associate tags with all metrics collected for this integration.

### Enable logs collection{% #enable-logs-collection %}

You may configure Mailgun to forward events as logs to Datadog. See the section **Tracking Messages - Webhooks** [in the Mailgun documentation](https://documentation.mailgun.com/en/latest/user_manual.html#webhooks-1) for more details.

1. Copy the generated URL from the instructions on the [Mailgun integration tile](https://app.datadoghq.com/integrations/mailgun).
1. Log in to your Mailgun account.
1. Click **Sending** in the left side column.
1. Click **Webhooks** in the dropdown.
1. Click **Add webhook** in the top right corner.
1. Select the Event type you want to track.
1. Paste in the generated URL in step 1 under **URL**.
1. Click **Create Webhook**.

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **mailgun.emails.accepted.total**(count)                                | Total number of emails accepted including both incoming and outgoing*Shown as email*                       |
| **mailgun.emails.accepted.incoming**(count)                             | Number of incoming emails accepted*Shown as email*                                                         |
| **mailgun.emails.accepted.outgoing**(count)                             | Number of outgoing emails accepted*Shown as email*                                                         |
| **mailgun.emails.delivered.total**(count)                               | Total number of emails sent and accepted by recipient email server*Shown as email*                         |
| **mailgun.emails.delivered.smtp**(count)                                | Number of SMTP emails sent and accepted by recipient email server*Shown as email*                          |
| **mailgun.emails.delivered.http**(count)                                | Number of HTTP emails sent and accepted by recipient email server*Shown as email*                          |
| **mailgun.emails.delivered.optimized**(count)                           | Number of Send Time Optimization emails sent and accepted by recipient email server*Shown as email*        |
| **mailgun.emails.failed.temporary.total**(count)                        | Number of emails that temporarily failed to be delivered to recipient email server*Shown as email*         |
| **mailgun.emails.failed.temporary.espblock**(count)                     | Number of emails that were blocked by the email service provider*Shown as email*                           |
| **mailgun.emails.failed.permanent.total**(count)                        | Number of emails that permanently failed to be delivered to recipient email server*Shown as email*         |
| **mailgun.emails.failed.permanent.suppress\_bounce**(count)             | Number of emails that were dropped due to a previous bounce*Shown as email*                                |
| **mailgun.emails.failed.permanent.suppress\_unsubscribe**(count)        | Number of emails that were dropped due to a previous unsubscribe*Shown as email*                           |
| **mailgun.emails.failed.permanent.suppress\_complaint**(count)          | Number of emails that were dropped due to a previous complaint*Shown as email*                             |
| **mailgun.emails.failed.permanent.bounce**(count)                       | Number of emails that were bounced instead of delivered*Shown as email*                                    |
| **mailgun.emails.failed.permanent.delayed\_bounce**(count)              | Number of emails that were bounced after a delay*Shown as email*                                           |
| **mailgun.emails.failed.permanent.webhook**(count)                      | Number of webhook requests failed*Shown as request*                                                        |
| **mailgun.emails.failed.permanent.optimized**(count)                    | Number of Send Time Optimization emails failed*Shown as email*                                             |
| **mailgun.emails.opened.total**(count)                                  | Total number of times emails were opened by recipients*Shown as email*                                     |
| **mailgun.emails.clicked.total**(count)                                 | Number of times links were clicked in the emails*Shown as email*                                           |
| **mailgun.emails.unsubscribed.total**(count)                            | Number of recipients who unsubscribed*Shown as email*                                                      |
| **mailgun.emails.complained.total**(count)                              | Number of recipients who complained*Shown as email*                                                        |
| **mailgun.emails.stored.total**(count)                                  | Number of stored incoming messages*Shown as email*                                                         |
| **mailgun.emails.hourly.accepted.total**(count)                         | Total hourly number of emails accepted including both incoming and outgoing*Shown as email*                |
| **mailgun.emails.hourly.accepted.incoming**(count)                      | Hourly number of incoming emails accepted*Shown as email*                                                  |
| **mailgun.emails.hourly.accepted.outgoing**(count)                      | Hourly number of outgoing emails accepted*Shown as email*                                                  |
| **mailgun.emails.hourly.delivered.total**(count)                        | Total hourly number of emails sent and accepted by recipient email server*Shown as email*                  |
| **mailgun.emails.hourly.delivered.smtp**(count)                         | Hourly number of SMTP emails sent and accepted by recipient email server*Shown as email*                   |
| **mailgun.emails.hourly.delivered.http**(count)                         | Hourly number of HTTP emails sent and accepted by recipient email server*Shown as email*                   |
| **mailgun.emails.hourly.delivered.optimized**(count)                    | Hourly number of Send Time Optimization emails sent and accepted by recipient email server*Shown as email* |
| **mailgun.emails.hourly.failed.temporary.total**(count)                 | Hourly number of emails that temporarily failed to be delivered to recipient email server*Shown as email*  |
| **mailgun.emails.hourly.failed.temporary.espblock**(count)              | Hourly number of emails that were blocked by the email service provider*Shown as email*                    |
| **mailgun.emails.hourly.failed.permanent.total**(count)                 | Hourly number of emails that permanently failed to be delivered to recipient email server*Shown as email*  |
| **mailgun.emails.hourly.failed.permanent.suppress\_bounce**(count)      | Hourly number of emails that were dropped due to a previous bounce*Shown as email*                         |
| **mailgun.emails.hourly.failed.permanent.suppress\_unsubscribe**(count) | Hourly number of emails that were dropped due to a previous unsubscribe*Shown as email*                    |
| **mailgun.emails.hourly.failed.permanent.suppress\_complaint**(count)   | Hourly number of emails that were dropped due to a previous complaint*Shown as email*                      |
| **mailgun.emails.hourly.failed.permanent.bounce**(count)                | Hourly number of emails that were bounced instead of delivered*Shown as email*                             |
| **mailgun.emails.hourly.failed.permanent.delayed\_bounce**(count)       | Hourly number of emails that were bounced after a delay*Shown as email*                                    |
| **mailgun.emails.hourly.failed.permanent.webhook**(count)               | Hourly number of webhook requests failed*Shown as request*                                                 |
| **mailgun.emails.hourly.failed.permanent.optimized**(count)             | Hourly number of Send Time Optimization emails failed*Shown as email*                                      |
| **mailgun.emails.hourly.opened.total**(count)                           | Total hourly number of times emails were opened by recipients*Shown as email*                              |
| **mailgun.emails.hourly.clicked.total**(count)                          | Hourly number of times links were clicked in the emails*Shown as email*                                    |
| **mailgun.emails.hourly.unsubscribed.total**(count)                     | Hourly number of recipients who unsubscribed*Shown as email*                                               |
| **mailgun.emails.hourly.complained.total**(count)                       | Hourly number of recipients who complained*Shown as email*                                                 |
| **mailgun.emails.hourly.stored.total**(count)                           | Hourly number of stored incoming messages*Shown as email*                                                  |

### Logs{% #logs %}

Mailgun events will show up as logs under the source `mailgun`.

### Events{% #events %}

The Mailgun integration does not include any events.

### Service Checks{% #service-checks %}

The Mailgun integration does not include any service checks.

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help).

## Further Reading{% #further-reading %}

- [Integration roundup: Understanding email performance with Datadog](https://www.datadoghq.com/blog/email-performance-integrations/)
