Overview
Mailgun (by Sinch) is an enterprise developer-centric email API engineered for high-throughput transactional and broadcast delivery. In BrokerOS, the Mailgun integration lives inintegrations/mail/mailgun/src/index.ts under the Turborepo workspace package @brokeros/int-mail-mailgun.
BrokerOS administrators configure Mailgun entirely within the Web UI at Dashboard -> Marketing -> Email -> Settings. All API credentials are encrypted with AES-256-GCM and stored in PostgreSQL (MarketingIntegration).
Architecture and Dispatch Sequence
The Mailgun integration implements theIEmailMarketingProvider contract from @brokeros/types. Outbound marketing and transactional emails submit form-encoded MIME requests to Mailgun’s v3 endpoint.
Step 1: Obtain Credentials from Mailgun
- Log into your Mailgun dashboard at app.mailgun.com.
- Navigate to Sending -> Domains and add your sending subdomain (e.g.
mail.skylinerealty.com). - Add the two TXT records (SPF and DKIM
k=rsa; p=...) and MX routing records provided by Mailgun into your DNS management console. - Navigate to Settings -> API Security and copy your primary Private API Key (starting with
key-). - Note your account region (US or EU).
Step 2: Connect in the BrokerOS Web Dashboard
In your BrokerOS dashboard:- Navigate to Dashboard -> Marketing -> Email -> Settings.
- Select the Providers & Domains tab (
/dashboard/marketing/email/settings?tab=providers). - Click Add Provider and choose Mailgun.
- Fill in the modal connection fields:
- Click Verify & Connect. BrokerOS connects to
GET /v3/domains/{domain}, verifies active domain status, encrypts the credentials via AES-256-GCM, and stores them inMarketingIntegration.
Step 3: Configure Webhook Endpoints in Mailgun
To stream live bounce, open, and click metrics into BrokerOS:- In Mailgun, go to Sending -> Webhooks.
- Add your BrokerOS webhook destination URL:
- Enable events for Delivered Messages, Permanent Failure, Temporary Failure, Clicks, Opens, and Unsubscribes.
- Save the webhook. BrokerOS
MailgunWebhookParserprocesses incoming callbacks automatically.
Webhook Event Telemetry Mapping
Integration Implementation Details
The Mailgun integration source code is located inintegrations/mail/mailgun/src/index.ts.
Multi-Region Resolution
The client dynamically resolves endpoints based on tenant configuration:Form-Encoded Dispatch
Outbound batches are encoded asapplication/x-www-form-urlencoded payloads: