> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.onesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mailgun Setup

> Step-by-step guide to setting up Mailgun with OneSignal for sending email messages. Includes DNS verification, SMTP credential setup, API key generation, and OneSignal integration instructions.

> [!WARNING]
>
> This setup guide is if you have Mailgun already and want to integrate it with OneSignal. If you don't have a Mailgun account, you can use [OneSignal Email](https://documentation.onesignal.com/docs/en/email-setup.md) instead.

## Requirements

* [Mailgun Account](https://www.mailgun.com)
* Mailgun **US** API (EU region is not supported)
* [OneSignal Account](https://onesignal.com)
* A domain you own and access to its DNS provider

***

## Setup

### 1. Add a new domain in Mailgun

Skip this step if your domain is already set up in the US region.

1. Go to the **Domains** page in the Mailgun dashboard.

![](https://mintcdn.com/onesignal/MUgio66t0sYhGEvj/images/docs/6e14df8-01_-_Navigate_to_sending_domains.png?fit=max\&auto=format\&n=MUgio66t0sYhGEvj\&q=85\&s=542d06f8870b8e98cdb276d475cb2d99)

Navigate to the Domains page

2. Click **Add new domain**.

![](https://mintcdn.com/onesignal/_KaXe4GQkxsEfa17/images/docs/403bd98-01.2_-_Click_Add_new_domain_button.png?fit=max\&auto=format\&n=_KaXe4GQkxsEfa17\&q=85\&s=d0d94e8e010730d7f80fb782f0bf3557)

Open Add New Domain form

3. Enter a subdomain (e.g., `mail.yourdomain.com`) and ensure the region is **US**.

![](https://mintcdn.com/onesignal/RWtLFPeffHrC81wI/images/docs/ad8dca5-01.3_-_Add_new_domain.png?fit=max\&auto=format\&n=RWtLFPeffHrC81wI\&q=85\&s=fa477b2191c6b916fb4e16a9bf457161)

Specify subdomain and select US region

### 2. Verify DNS settings

Mailgun provides the following DNS records:

* 2 **TXT** (SPF & DKIM)
* 2 **MX**
* 1 **CNAME**

Update these in your DNS provider. Propagation may take up to 48 hours. Mailgun will notify you via email once verified.

To verify:

* Go to **Mailgun > Sending > Domain Settings > Your Domain > DNS Records**
* Look for green checkmarks next to each record

![](https://mintcdn.com/onesignal/Z6xkXGfmy814If53/images/docs/ddbf617-01.5_-_Verified_DNS_settings.png?fit=max\&auto=format\&n=Z6xkXGfmy814If53\&q=85\&s=26bd8596b9ac4b96089b8225c00fa94d)

Verify DNS setup

> [!NOTE]
>
> If CNAME is not set correctly, email click and open tracking will not work.

***

### 3. Set up SMTP credentials

1. Go to **Sending > Domain Settings > SMTP credentials** in Mailgun.

![](https://mintcdn.com/onesignal/tc0EvmtSSX56SX0c/images/docs/963d676-02_-_Add_SMTP_creds.png?fit=max\&auto=format\&n=tc0EvmtSSX56SX0c\&q=85\&s=2cb892039a5cfee55aa25da01ae438e1)

Navigate to SMTP Credentials

2. Click **Add new SMTP user**.

![](https://mintcdn.com/onesignal/56ctKxZSV4m5VEkn/images/docs/b2108d4-02.1_-_Click_Add_new_SMTP_user.png?fit=max\&auto=format\&n=56ctKxZSV4m5VEkn\&q=85\&s=79537c0dae456ed4320ad09647db4d87)

Add new SMTP credentials

3. Set a login name and save the credentials.

![](https://mintcdn.com/onesignal/9_Q1FZLh6C0BFLq-/images/docs/be7540c-03_-_New_SMTP_creds.png?fit=max\&auto=format\&n=9_Q1FZLh6C0BFLq-\&q=85\&s=53a10a727d7dbb9a8234332e50e3308e)

Create SMTP user

4. Click the **copy** icon to save the password securely.

![](https://mintcdn.com/onesignal/RWtLFPeffHrC81wI/images/docs/ab32f9b-03.1_-_Copy_SMTP_user_pass.png?fit=max\&auto=format\&n=RWtLFPeffHrC81wI\&q=85\&s=51aeb4db620490e077f63465619e2711)

Copy SMTP password

### 4. Get a Mailgun API key

1. In the Mailgun dashboard, scroll to the bottom and click **API Keys**.

![](https://mintcdn.com/onesignal/YOTSrtBSoqdrJ37A/images/docs/430314e-42fc46d-step-1-50.png?fit=max\&auto=format\&n=YOTSrtBSoqdrJ37A\&q=85\&s=f80af7cfcfe4be2d94418b6f15448097)

Navigate to API Keys

2. Click **Add new key**

![](https://mintcdn.com/onesignal/MUgio66t0sYhGEvj/images/docs/6390d56-93a49a5-step-2-50.png?fit=max\&auto=format\&n=MUgio66t0sYhGEvj\&q=85\&s=45c91e47914b90b577388c8c26fc9538)

Add new key

3. Name the key and click **Create Key**.

![](https://mintcdn.com/onesignal/6v_cVPknFpo5qSVB/images/docs/09dd33b-6faf199-step-3-50.png?fit=max\&auto=format\&n=6v_cVPknFpo5qSVB\&q=85\&s=87af7bad8fc8363e916e5673779a65ea)

Create key

4. Copy the generated API key and save it securely.

![](https://mintcdn.com/onesignal/tNi1OgLc_p9hiq7_/images/docs/1350337-cb5aeba-step-4-50.png?fit=max\&auto=format\&n=tNi1OgLc_p9hiq7_\&q=85\&s=d4f1a03d0287b8c3169bda289b839cfa)

Copy API key

***

### 5. Configure Mailgun in OneSignal

1. In OneSignal, go to **Settings > Platforms > Email** and choose **Mailgun**.

![](https://mintcdn.com/onesignal/tc0EvmtSSX56SX0c/images/docs/9341a6c-01_-_App_setup_email.png?fit=max\&auto=format\&n=tc0EvmtSSX56SX0c\&q=85\&s=2c645ab6c1107ed5bb1122aacff78d17)

App setup email

2. Select **Mailgun** as the provider.

![](https://mintcdn.com/onesignal/YOTSrtBSoqdrJ37A/images/docs/4a2a57c-02_-_App_Setup_Email_Mailgun.png?fit=max\&auto=format\&n=YOTSrtBSoqdrJ37A\&q=85\&s=d7bcb86f6bc0d15df9b49a147d132959)

App setup email

3. Enter:

* The domain from [Step 1](#1-add-a-new-domain-in-mailgun)
* SMTP credentials from [Step 3](#3-set-up-smtp-credentials)
* API key from [Step 4](#4-get-a-mailgun-api-key)

![](https://mintcdn.com/onesignal/6v_cVPknFpo5qSVB/images/docs/07c6b2f-03_-_Configure_provider.png?fit=max\&auto=format\&n=6v_cVPknFpo5qSVB\&q=85\&s=a3cb35435c5496d52c08135bed6c99d0)

Configure provider

4. Set default sender name and `from` email address.

![](https://mintcdn.com/onesignal/6tscVAtiSqz353kV/images/docs/9e6af63-04_-_Configure_additional_settings.png?fit=max\&auto=format\&n=6tscVAtiSqz353kV\&q=85\&s=7c34b6e400662d67808226872626e1de)

Configure additional settings

### 6. Add OneSignal webhooks to Mailgun

Navigate to **Mailgun > Sending > Webhooks > Your Domain > Webhooks** and add:

```
https://onesignal.com/email/hooks/mailgun
```

![](https://mintcdn.com/onesignal/Z6xkXGfmy814If53/images/docs/d81f4cc-Screenshot_2023-01-25_at_3.48.04_PM.png?fit=max\&auto=format\&n=Z6xkXGfmy814If53\&q=85\&s=30721d7d06a88cae8fc244577f767a89)

Add webhook

### 7. Change tracking protocol to HTTPS

Ensure recipients are directed to secure URLs.

1. Go to your domain settings in Mailgun.
2. Under **Tracking > Tracking Protocol**, change from **HTTP** to **HTTPS**.

![](https://mintcdn.com/onesignal/Xl2NHJvxakrK4JbL/images/docs/e79e542-Screenshot_2023-01-25_at_3.52.26_PM.png?fit=max\&auto=format\&n=Xl2NHJvxakrK4JbL\&q=85\&s=bfb73b54c1f4a81ae480cdfda0413966)

Change tracking protocol

### 8. Send a test email

1. Go to **OneSignal > Messages > Email**, click **New Email**.
2. Add a subject, click **Send Test Email**, input your email, and hit **Send Test Message**.

![](https://mintcdn.com/onesignal/YOTSrtBSoqdrJ37A/images/docs/46aaab5-Screen_Shot_2021-11-18_at_6.00.46_PM.png?fit=max\&auto=format\&n=YOTSrtBSoqdrJ37A\&q=85\&s=5d3969be38e8e9caea691fdb094a54c7)

Send test email

You should receive the test email shortly.

***

## Troubleshooting

See our [Email FAQ](https://documentation.onesignal.com/docs/en/email-troubleshooting.md)

> [!NOTE]
>
> Need help?
>
> Chat with our Support team or email `support@onesignal.com`
>
> Please include:
>
> * Details of the issue you're experiencing and steps to reproduce if available
> * Your OneSignal App ID
> * The External ID or Subscription ID if applicable
> * The URL to the message you tested in the OneSignal Dashboard if applicable
> * Any relevant [logs or error messages](https://documentation.onesignal.com/docs/en/capturing-a-debug-log.md)
>
> We're happy to help!

***

> [!TIP]
>
> Email setup complete!
> **Next steps:**
>
> * Return to the [Email Setup guide](https://documentation.onesignal.com/docs/en/email-setup.md) to explore OneSignal Email capabilities.

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.