Skip to content

Mailgun

Connect your Mailgun account to Optail.

  1. Log in to the Mailgun dashboard
  2. Go to Settings > API Security
  3. Copy your Private API key (or generate a new one)
  4. Note your sending domain (e.g., mg.yourdomain.com)
  1. Go to Providers > Connect Provider
  2. Select Mailgun
  3. Enter a display name (e.g., “Mailgun Production”)
  4. Enter your API key and sending domain
  5. Click Connect — Optail validates by querying your domain info
Terminal window
curl -X POST https://api.optail.io/v1/providers \
-H "Authorization: Bearer ms_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"providerType": "MAILGUN",
"displayName": "Mailgun Production",
"credentials": {
"apiKey": "key-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"domain": "mg.yourdomain.com"
}
}'

If you have not already set up your domain in Mailgun:

  1. In Mailgun, go to Sending > Domains > Add New Domain
  2. Enter your sending domain (recommended: use a subdomain like mg.yourdomain.com)
  3. Add the required DNS records:
    • TXT record for SPF
    • TXT records for DKIM (two CNAME records)
    • MX records for receiving (if needed)
    • CNAME record for tracking
  4. Click Verify DNS Settings

To receive delivery events in Optail:

  1. In Mailgun, go to Sending > Webhooks
  2. For each event type, set the URL to: https://webhooks.optail.io/v1/ingest/mailgun
  3. Configure events: Delivered, Opened, Clicked, Bounced (Permanent Failure), Complained, Unsubscribed, Failed (Temporary)

Mailgun requires setting the webhook URL per event type individually.

FieldDescription
apiKeyMailgun Private API key (starts with key-).
domainVerified sending domain (e.g., mg.yourdomain.com).