AFI AFI

Mailgun

Estimated reading: 2 minutes Updated August 1, 2026

Mailgun is a developer-focused email API for transactional and marketing email. Advanced Form Integration sends form submissions to Mailgun as new mailing-list members. the Pro version adds transactional email send.

What you’ll need

  • An active Mailgun account with at least one verified sending domain.
  • Your Mailgun Private API key (Account Settings → API Keys).
  • Your Mailgun region (US or EU; they use different API endpoints).
  • The Advanced Form Integration plugin installed and activated.

Connect Mailgun to AFI

  1. In WordPress, go to AFI → Settings → Mailgun.
  2. Enter the API key and pick the region.
  3. Click Save Changes.

Create the integration

  1. Go to AFI → Add New.
  2. Configure the trigger.
  3. In Action → Platform, select Mailgun.
  4. In Task, choose Add Member to Mailing List.
  5. Pick the Mailing List (one of the lists configured in Mailgun under Sending → Mailing Lists).
  6. Map the form fields:
  • Email (required), Name.
  • Subscribed (yes/no): controls whether the member receives broadcasts.
  • Custom variables passed as JSON, accessible inside Mailgun templates.
  1. Optional: configure Conditional Logic.
  2. Click Save Integration.

Screenshot: AFI field-mapping screen with Mailgun mailing list and member fields visible

Pro features

The Pro Mailgun integration unlocks transactional send. Fire a one-off templated email when the form is submitted (welcome email, receipt, lead magnet delivery), with form fields available as merge variables in the Mailgun template.

Conditional logic example

Subscribe to your “Beta testers” mailing list only when the form’s tester_signup checkbox is checked. Other newsletter signups go to a different list via a separate integration.

Troubleshooting

“Authentication failed”

Verify the region matches your Mailgun account. US-region accounts use api.mailgun.net, EU-region accounts use api.eu.mailgun.net. Mismatched region returns 401.

Member added but no emails sent

A mailing list member is just a subscriber record. To actually send email, use Mailgun’s broadcast features or the Pro transactional send.

Related docs