If you'd like to use Mailgun you will need to configure a domain or at least a hostname in a domain that will be used to send out the messages.

You'll need to tell the world using SPF1 and DKIM1 records that the IP addresses of Mailgun are approved to send out messages of your domain.

This will increase the likelihood of your messages arriving to their destinations and not flagged out by SPAM filters.

They have instructions for various DNS providers, but I have not seen instructions for plain old Bind9 files and it took me a while to figure them out, but now here they are:


; For Mailgun:
mg                  3600 IN TXT    "v=spf1 include:mailgun.org ~all"
mx._domainkey.mg    3600 IN TXT    ("v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKPkTXnvRQ6KIc0sA3FOZea5nunP3FhJVp6JKDkt7pqo5mtduiA/tN6E7OrE8rzgrWI50+DVYSMwxfOb5d9WLhwVlVc20dFM4ibTkcYNwDsZtPZHIbYpV/3hMjKIyZ1pauAmU05Lp0dtjf9vucIfdu4ysFol2rdenRNTt1Z+WwVwIDAQAB");

mg   3600   IN   MX    10    mxa.mailgun.org.
mg   3600   IN   MX    10    mxb.mailgun.org.
email.mg   3600   IN   CNAME  mailgun.org.

In this case I registered the mg hostname as in mg.hostocal.com.

Verify your configuration

There is a detailed explanation by Mailgun.

Here are the commands I used (on a Linux system):

dig -t MX mg.hostlocal.com

dig -t TXT mg.hostlocal.com

dig -t TXT mx._domainkey.mg.hostlocal.com