Mailgun Setup

How to setup Mailgun for use in OneSignal Email Messaging

OneSignal's Email Messaging requires the use of a third-party email service provider to handle email delivery. All you have to do is set up the integration between the provider and OneSignal, and you'll be ready to send emails through OneSignal.

Requirements

📘

Don't have a Domain, DNS Provider or Email Service Provider?

No problem! Contact OneSignal's Sales Team and ask about Email Onboarding.

Setup

1. Add a new domain in Mailgun

Skip to step 2 if you already have a domain setup in the US region with Mailgun.

From the Mailgun dashboard, navigate to the Domains page.

Navigating to the Domains page

Navigating to the Domains page

  1. Click the Add new domain button
Navigating to Add New Domain form

Navigating to Add New Domain form

  1. Configure the domain
Specifying a subdomain and selecting the US Domain region

Specifying a subdomain and selecting the US Domain region


2. Verify DNS settings

You will be given two TXT (SPF and DKIM), two MX, and a CNAME record. Update these records in your DNS provider. It may take up to 48 hours (usually less) to propagate. Mailgun will email you once complete.

Check-in Mailgun > Sending > Domain settings > Your Domain > DNS records. Green checkboxes will show next to each record correctly identified. If the CNAME is missing, you will not get email click, open, and unsubscribe tracking.

Confirming verification after adding records to DNS

Confirming verification after adding records to DNS


3. Setup SMTP Credentials

From the Mailgun dashboard navigate to Sending > Domain settings > SMTP credentials.

Navigating to the SMTP Credentials page

Navigating to the SMTP Credentials page

  1. Click Add new SMTP user button
Navigating to the New SMTP credentials form

Navigating to the New SMTP credentials form

  1. Provide user with a login name
Creating the login

Creating the login

  1. Save credentials for later
Clicking the copy button will add the password to your clipboard.

Clicking the copy button will add the password to your clipboard.


4. Get a Mailgun API key

  1. Navigate to your Mailgun dashboard and click the API Keys located in the bottom-right of the page
  1. Click Add new key

  1. Enter a name for your key and click Create Key

  1. Copy your API key.

5. Configure OneSignal email

  1. After all your DNS records are verified, go to OneSignal and navigate to Settings > Platforms > Email.
    Select Mailgun and Continue.
  1. Select Mailgun as email provider.
  1. Enter the domain from Step 1 - Add a new domain, the SMPT login details from Step 3 - Create SMTP Credentials, and the API key from Step 4 - Create an API key.
  1. Provide default values for the sender name and the email address that will appear in the from header if none are specified when creating an email.

6. Add OneSignal Webhooks to Mailgun

Within Mailgun Sending > Webhooks > Your Domain > Webhooks.

This should be pointing to https://onesignal.com/email/hooks/mailgun

7. Change Tracking Protocol to HTTPS

This will make sure that when recipients click on links within your emails they are brought to a secure page that does not show a warning that the link is not secure.

Go to your domain and navigate to Domain Settings.

Under Tracking > Tracking Protocol change the setting from HTTP to HTTPS

8. Add Email Subscriptions

If you have a list of emails ready, select Upload CSV to Import Email Addresses. You can always do this again later.

If you have a website and want to prompt users to provide their email. Select Add Web Prompt to use OneSignal's Email Web Prompt.

9. Send Yourself a Test Email

In OneSignal > Messages > Email, select New Email.

Add a Subject and click Send Test Email. Input your email and press Send Test Message.

An email should arrive to your inbox shortly!

📘

Troubleshooting

If running into issues, see our Email FAQ.

If stuck, contact support directly or email [email protected] for help.

For faster assistance, please provide:

  • Your OneSignal App Id
  • Details, logs, and/or screenshots of the issue.
  • Steps to reproduce

Recommended

Identify Users

Required if using integrations.
Recommended for messaging across multiple channels (push, email, sms).

OneSignal creates subscription-level records under a unique ID called the subscription_id. A single user can have multiple subscription_id records based on how many devices, email addresses, and phone numbers they use to interact with your app.

If your app has its own login system to track users, call login at any time to link all channels to a single user. For more details, see Aliases & External ID.

Add Data Tags

Optional

Tags are custom key : value pairs of String data used for tracking user events and properties. Setting tags is required for more complex segmentation and message personalization.

See Data Tags for more details.

Collect New Emails

Emails can be added into OneSignal using the following options outlined in our Import Email Addresses guide.

OptionDescription
Dashboard UploadUpload a csv of emails and user data or manually add emails.
Server APIProgrammatically add emails server side.
SDK addEmail methodAdd emails using our client side SDK. Recommended if using our SDKs for push or in-app messaging.
Email Web PromptA web prompt that allows user to include their own email address and phone number.

👍

Setup Complete!

Visit Email Tutorials for next steps.

FAQ

How do I allowlist OneSignal's IPs?

See the requirements in our REST API Overview for details.


What’s Next