Skip to content
BuildBase

Send through Mailgun from a verified domain

Connect your Mailgun account, add a sending domain, publish its DNS records and verify it, then add a Mailgun sender on it, in the console or with the API.

A Mailgun sender sends from an address on a verified domain. Adding a domain returns the DNS records to publish; verification checks them and unlocks sending. SMTP, Google and Amazon SES senders need no sending domain here: their domain is authenticated at that provider (connect a sender).

Before you start

A Mailgun account, access to your domain's DNS where you bought it, and a console role that can create email senders and domains. Send from a subdomain, such as mail.acme.example, if the domain itself already receives mail.

Set it up in the console

Open Sender accounts in the console

(opens the console in a new tab)

1. Open the Domains tab

In the left rail choose Messaging, then Sender accounts, and open the Domains tab. Before a Mailgun account is connected, it offers Add credential.

The Domains tab of Sender accounts, highlighted as step 1, with Manage domains and its Add credential button highlighted as step 2

2. Connect your Mailgun account

Press Add credential. How to get your Mailgun API key says where Mailgun keeps it: the menu under your name, then API security. Paste the API key, and the HTTP webhook signing key from the same page into Webhook signing key (optional). Press Add credential.

The Add credential sheet: How to get your Mailgun API key, the API key highlighted as step 2, the Webhook signing key, the webhook address with Copy webhook URL, and the Add credential button

3. Send Mailgun's reports back

Press Copy webhook URL: your organization's own address on BuildBase, ending /mailgun. In Mailgun, open your domain's Sending, then Webhooks, and add it for the permanent failure, complaint and unsubscribe events. Without it, and without the signing key, BuildBase never learns which addresses bounced.

4. Add the domain

Back on Domains, press Create domain, fill Domain in Create new domain, and press Create domain. BuildBase adds it to your Mailgun account and lists its records.

5. Publish its DNS records

The domain's card lists its Sending DNS records, each with its type, name and value, under How to add these records where you bought your domain. Add each TXT and CNAME record at your DNS host exactly as shown. Add the Receiving DNS records (MX) only if replies should go to Mailgun.

6. Verify it

Press Verify. Each record moves from Unverified to Verified once DNS has it, and the button becomes Recheck. Nothing checks again by itself: press it later if a record was still on its way.

7. Add a Mailgun sender on it

On the Accounts tab, press Add new sender and choose Mailgun. Pick the Domain, fill Sender name and Sender email, and press Create. Only a verified domain can be picked.

The Mailgun tab of Add new sender: the note that Mailgun sends only from a domain that has proved it is yours, highlighted as step 7, then Domain, Sender name and Sender email

Check it works

The domain reads Verified, its DMARC row shows a policy, and Send test email on the new sender arrives.

With the API

# 1. Add the domain
curl -X POST https://api.console.buildbase.app/api/emails/domains \
  -H "Authorization: Bearer $BUILDBASE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain":"mail.example.com"}'

# 2. Publish the returned records in DNS, then verify
curl -X POST https://api.console.buildbase.app/api/emails/domains/$DOMAIN_ID/verify \
  -H "Authorization: Bearer $BUILDBASE_TOKEN"

Records

Creating a domain stores two record sets returned by Mailgun:

SetPurpose
Sending recordsAuthorize BuildBase to send as the domain. Publish all of them
Receiving recordsMX records, needed only if the domain should receive mail

Publish every sending record exactly as returned. The console lists them with their type, name, and value, ready to copy into your DNS provider.

A subdomain such as mail.example.com is the usual choice - it keeps sending reputation and DNS separate from your apex domain.

Verifying

POST /api/emails/domains/:id/verify re-checks DNS and returns the updated domain document.

OutcomeResponse
Verified200 with the domain object
Not yet propagated, or a record is wrong400 with { "success": false, "message": "…" }

The 400 uses success: false, unlike most API errors which use error: true.

Verification is not automatic - nothing retries it in the background. Call it again after DNS propagates, which typically takes minutes but can take hours depending on your provider's TTL.

A successful verification emits email.domain.verified, so a workflow can notify the team rather than having someone poll the console.

Endpoints

MethodPathPurpose
GET/api/emails/domainsList domains, paginated
GET/api/emails/domains/:idOne domain, including its records
POST/api/emails/domainsAdd a domain
POST/api/emails/domains/:id/verifyRe-check DNS

Gmail Postmaster Tools

Connect a verified domain to Gmail Postmaster Tools to see Gmail's own spam rate, reputation and SPF, DKIM and DMARC results for it, on the domain and next to the Gmail row of each campaign report. See Gmail Postmaster for the steps, what is read and the endpoints.

Senders

A sender is an address mail goes out from, through SMTP, Google, Amazon SES, or Mailgun on a verified domain. One sender per organization is the default: it sends the organization's own mail (sign-in codes, password resets, invitations) and any other email sent without naming a sender. A campaign always names its sender. A Google sender is connected through an OAuth callback rather than a stored password.

Access is enforced at three distinct levels - sharing a sender does not hand over control of it:

ActionWho can do it
List sendersIts creator, anyone it is shared with, and org owners and admins
Read one senderIts creator, anyone it is shared with, and org owners and admins
Update, delete, set as defaultIts creator, or an org owner or admin
Share, unshare, manage shared usersIts creator only, with no override for owners or admins

The split is the part worth noting: an org owner or admin can change or delete any sender, and still cannot change who else it is shared with.

An SMTP or Gmail sender reports bounces (mail that came back undelivered) by mailing them back, not by webhook. Turn on bounce tracking in its edit dialog, and BuildBase reads those notices from its mailbox every ten minutes. See Bounce intake.

Verifying a domain also looks up its DMARC policy, the DNS record Gmail and Yahoo require from bulk senders. It shows as one more DNS row, or as the record to publish if there is none. See DMARC.

Next Steps