Mailgun
Send emails with Mailgun via Courier. Covers profile setup, overrides, attachments, EU host config, delivery webhooks, and error handling.
Overview
Send Mailgun emails through Courier with full support for overrides, attachments, and real-time delivery status.
Profile Requirements
Courier uses the email
key in the recipient profile to send messages through Mailgun.
Override Configuration
Use the override
object to customize the payload sent to Mailgun’s Messages API. Example: add a Mailgun tag.
Courier replaces the full request body with the contents of override
.
To customize the fromAddress
or other Mailgun config options, set them under override.config
.
Refer to the Mailgun API docs for supported parameters.
To send through Mailgun’s EU region, set the host
value to api.eu.mailgun.net
.
Attachments
To include attachments, add an attachment
array in the override. File content must be base64-encoded.
IP Allowlisting
Mailgun supports IP allowlists for API access. Courier runs on AWS and doesn’t use fixed outbound IPs.
To manage this, AWS provides a workaround:
Subscribe to the AmazonIpSpaceChanged
SNS topic. You’ll get notified whenever AWS updates its IP ranges, so you can update your allowlist accordingly.
Webhooks for Delivery Status
Courier polls Mailgun for status by default. To get real-time delivery updates, set up Mailgun webhooks.
Copy the Courier Webhook URL
In Courier, go to the Mailgun configuration page. Copy the generated Webhook URL.
Configure Webhooks in Mailgun
In Mailgun, navigate to Sending → Webhooks.
Add a webhook for Delivered Messages, and paste the URL.
Repeat for Permanent Failure.
Match the Domain
In Mailgun, ensure the selected domain matches the one configured in Courier.
Disable Polling (optional)
After ~1 hour (to allow in-flight updates), disable polling in Courier under Enable polling for status updates, then click Save.