
Connect
1
Open the Mailgun integration in Brew
In Brew, go to Integrations and click the Mailgun card.
2
Copy your domain name
In Mailgun, go to Sending → Domains, select your domain, then click Domain settings. Copy your domain name and paste it into the first field in Brew.
3
Copy your private API key
Click your profile icon in the top right corner, then go to API Security. Click the eye icon next to your Private API Key to reveal it, then copy it.
4
Paste and connect
Go back to Brew, paste the API key into the second field, and click Connect.
Export a Template
Once connected, you can export any email to Mailgun:- Open an email you’ve created in Brew
- Click Send
- Choose to export the template to Mailgun
- Give it a name, check the subject line, and click Export
Where It Lands
The template appears in Mailgun under Send → Sending → Templates, in the domain-level templates for your sending domain. Its description says it came from Brew.Merge Tags and Unsubscribe Link
Mailgun fills a template only from the variables you send with the message (t:variables or the X-Mailgun-Template-Variables header). Brew keeps each field’s name, so send the same keys:
The recipient’s address doesn’t fill
{{ email }}; include email in the variables if the template uses it. Liquid logic such as {% if %} or a filter like upcase has no Mailgun equivalent. Brew stops the export and names the tag.
The unsubscribe link becomes %mailing_list_unsubscribe_url%, which unsubscribes the recipient from the mailing list the message went to. Mailgun’s other unsubscribe variables cover other scopes; see its unsubscribe docs for the domain settings each one needs.
Mailgun reference: templates and unsubscribes.
From an Agent or Code
From an agent,export_email over MCP exports a design to Mailgun. From code, send POST /v1/emails/{emailId}/export with "provider": "mailgun". Connect Mailgun in the app first.
Export is free. Pass dryRun: true to check the design and the connection without creating a template. A dry run doesn’t test whether Mailgun accepts the template: only a real export does.
The template takes the email’s title unless you pass templateName (up to 100 characters), and the response returns its templateId. If an export fails, the error says why:
INTEGRATION_NOT_CONNECTED: Mailgun isn’t connected to this brand. Connect it on the Integrations page.EXPORT_UNSUPPORTED: Mailgun rejected a field value it doesn’t support. Change the value and export again.EXPORT_PROVIDER_ERROR: Mailgun refused or failed the export. Check the connection and retry.
Requirements
- A Mailgun account with a verified domain
- Your domain name (found under Sending → Domains → Domain settings)
- Your Private API Key (found under Profile → API Security)
Need Help?
Our team is ready to support you at every step of your journey with Brew. Choose the option that works best for you:- Self-Service Tools
- Talk to Our Team
Search Documentation
Type in the “Ask any question” search bar at the top left to instantly find relevant documentation pages.
Ask ChatGPT or Claude
Click here to open the Copy page menu at the top of this page, then send the page to ChatGPT, Claude, or your editor.