Skip to content
Docs

Send white-label email with Mailgun

Connect Mailgun to Voice AI Portal with your account API key, your sending domain and its region, and every email the portal sends for your agency goes out through Mailgun from your own domain: sign-in codes, client user welcomes, team invites, client billing emails and outbound email campaigns. When you save, the portal adds delivery webhooks to your Mailgun domain, so it records whether each email is delivered, bounced or marked as spam.

This guide is one of five sender guides. For a comparison, see Configure custom email.

  • Owner access. The Email Hub is in Settings, which only the agency owner opens.
  • A Mailgun account with a sending domain, for example mg.youragency.com. Mailgun suggests a subdomain, which keeps your main domain’s email untouched.
  • Access to your domain’s DNS, to verify the sending domain.
  • To know the domain’s region. Mailgun keeps US and EU domains apart, and the portal needs to know which one yours is in.

Step 1: Add and verify your sending domain in Mailgun

Section titled “Step 1: Add and verify your sending domain in Mailgun”
  1. Add the domain

    In Mailgun, open your domains and add your sending domain, choosing the US or EU region. Note which one you chose.

  2. Add the DNS records

    Mailgun shows the records for the domain. Add them at your DNS host exactly as shown:

    Type What it does
    TXT (SPF), with include:mailgun.org Lists Mailgun as allowed to send for the domain. A domain has only one SPF record, so if it already has one, add include:mailgun.org to it rather than creating a second.
    TXT (DKIM) Signs each email so mailbox providers can check it came from your domain.
    MX Only needed to receive email on the sending domain.
    CNAME Used by Mailgun’s own tracking. The portal keeps Mailgun’s open and click tracking off for its emails.
  3. Verify

    Mailgun checks the records for you, or select Verify DNS settings in the domain’s settings. Mailgun says DNS changes can take 24 to 48 hours, often less. The domain is ready once Mailgun shows it as active.

  4. Add DMARC (recommended)

    If your domain has no DMARC record, add a TXT record named _dmarc with the value v=DMARC1; p=none;.

Mailgun’s guides: Domain Verification (opens in a new tab) and DNS frequently asked questions (opens in a new tab).

Open the profile menu in Mailgun, then API Security, and create or copy an account API key (older Mailgun pages call it the Private API key). Mailgun shows a new key only once. Use the account key, not a domain sending key from the domain’s settings: a sending key can’t set up delivery tracking, and the portal refuses it.

The portal uses the key to check your domain, read the account’s webhook signing key, add and remove its delivery webhooks, and send your emails. If your account gives keys roles, choose one that allows all of these.

Mailgun’s guide: Where can I find my API keys and SMTP credentials? (opens in a new tab)

  1. Open the Email Hub

    Go to Settings and open the Email Hub tab. In Your email sender, under How you send, select Mailgun.

  2. Fill in the fields

    Field What to enter
    Mailgun API key The account API key. It is encrypted at rest and never shown again. When you edit other fields later, leave it blank to keep the saved key.
    Sending domain The domain exactly as it appears in Mailgun, for example mg.youragency.com.
    Region US or EU, matching the domain’s region in Mailgun.
    Reply-to Email Where client replies go, for example support@youragency.com.
    From Name Your agency name as clients see it.
    From Email An address on the sending domain, for example hello@mg.youragency.com.
  3. Select Save Sender Settings

    The portal checks that the key works and that the domain is in your Mailgun account in that region, before saving anything. It then reads your webhook signing key, adds its webhook to the domain and shows Connected to Mailgun and saved.

If you change the Sending domain or Region later, enter the key again.

Badge What it means
Domain verified Mailgun reports the domain as active. Your emails go out from your address.
Domain not verified in Mailgun Mailgun hasn’t activated the domain yet. Finish the DNS records in Mailgun.

The badge is read from Mailgun when you save. After Mailgun activates the domain, select Save Sender Settings again (the key is kept), or send a test email from an address on the sending domain.

Enter an address next to Send Test Email and select Send Test Email. Check that it arrives from your From Email and that replies go to your Reply-to Email. If the message says the test went out from the platform address, Mailgun refused it and the message gives Mailgun’s reason. You can send up to 10 test emails an hour.

When you save, the portal adds a webhook URL to your sending domain in Mailgun for the delivered, permanent failure, temporary failure and complained events. It points to app.voiceaiportal.com with a private address for your agency. Mailgun signs each event with your account’s webhook signing key, and the portal checks the signature and refuses events older than 12 hours. You don’t need to copy or paste anything, and you shouldn’t edit or delete the webhook in Mailgun.

Mailgun event What the portal records
Delivered Delivered
Failed, permanent Failed, with Mailgun’s reason
Failed, temporary Delivery delayed (Mailgun keeps trying)
Complained Marked as spam

Opens and clicks are not tracked, and tracking is off for these emails, so sign-in links always work exactly as sent.

Mailgun sometimes applies a webhook change a little late. Each time you send a test email, the portal checks the domain’s webhooks and puts its own back if it is missing.

The Email Hub shows Delivery tracking on. Last update with the time the last event arrived. If it shows Delivery tracking off, sending still works and the reason is shown next to it. Mailgun allows a limited number of webhook URLs per event on a domain; if they are all used, remove one you no longer need and save again with the key.

What happens if Mailgun can’t send an email?

Section titled “What happens if Mailgun can’t send an email?”
  • Mailgun refuses it (for example the domain isn’t active, or the key was revoked): the email goes out from the Voice AI Portal address instead, under your From Name and with your Reply-to Email, so your client still gets it.
  • Mailgun is busy or briefly unavailable: the portal retries before it moves to the platform address.
  • The recipient’s address is invalid: the email is not sent from another address.
  • Outbound email campaigns never use the platform address. If Mailgun refuses a campaign email because of your setup, the campaign pauses with the reason. See Email campaigns.

Can I send email campaigns through Mailgun?

Section titled “Can I send email campaigns through Mailgun?”

Yes. An email campaign playbook is ready once the badge shows Domain verified and your From Email is on the Sending domain itself, for example hello@mg.youragency.com. A From address on another domain keeps the playbook on “Verify your sending domain in Settings → Email Hub first”. See Email campaigns.

Problem What to do
“Enter your Mailgun sending domain, such as mg.yourdomain.com” Enter the domain name only, without https:// or a path.
“… isn’t in this Mailgun account (US region). Check the domain and region. Nothing was saved.” Check the spelling, and switch Region to EU if the domain was created in the EU region (or the other way round).
“Mailgun rejected this API key (…). Use the Private API key, not a domain sending key. Nothing was saved.” Copy an account API key from API Security and save again.
“Couldn’t reach Mailgun (…). Nothing was saved.” Wait a moment and save again.
“Enter the Mailgun API key again: it is needed when the account settings change” You changed the domain or region. Paste the key and save.
Delivery tracking off: “Mailgun didn’t return the webhook signing key (…)” Check the key is an account key that can read the signing key, then save again with the key.
Delivery tracking off: “Mailgun didn’t accept the delivery webhook (…)” Check the domain’s webhooks in Mailgun, remove any you no longer use, then save again with the key.
Domain not verified in Mailgun after Mailgun shows the domain as active Select Save Sender Settings again to read the new state.
“Too many changes to your email settings. Try again in an hour.” The Email Hub accepts 10 saves an hour.

Select Disconnect Mailgun and confirm. The saved key is removed, the portal’s webhook is removed from your Mailgun domain, and your emails go out from the platform address straight away. Your sender details stay. Switching to another sender also removes the webhook.