Spam Prevention

Authentication is a way to prove an email isn’t forged. There are a variety of authentication methods, and there’s no best method. SPF and SenderID allow a domain owner to add a file or record on the server that the recipient server cross-checks. These are easy to implement, but some suggest they aren’t as secure. DKIM and DomainKeys embed information within the email, making it harder to forge (but they can also be harder to implement for senders and receivers).

Since there are pros and cons to the various methods, we provide support for all of the above methods.


If you don’t have an SPF record yet, you’ll need to add one for your domain. At a minimum, the value should be the following if you’re only sending mail through Mailgun for that domain:

v=spf1 ~all

If you already have a TXT record with SPF information, you’ll need to add MailGun’s servers to that record by adding in the record (before the last operator, which is usually ?all, ~all, or -all).


Add a new TXT record with the name (just replace with the domain you’re setting up).

The value for the record should be one of the options listed below. There are two options because the record contains semicolons. Some DNS providers escape semicolons for you, while others require you to do it when setting up the record.

k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDPrcRtv+6d7FsQZImX72SikUCm6EStg2a0H3DEk5ppR8x0WKvB3uxukkhOnSiVfh0NzUvFLQ+gDdv/DHi9w357RqcCEfFHSfmuQOAIKbSVKkLeFiojQOf2ssZYSBInxQkO5WQrhTvPSoaKRPitp4jjOLUCoxHwPahFUhD3++FR0QIDAQAB