Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please help to set up a SPF record. I have found several SPF record generators but all questions are too complicated and I am afraid to make something wrong.

I want to allow sending mail only from:

1) from all IP addresses that are listed as A records for this domain. 2) from other servers in my data center in the same IP range 2) from Gmail servers - my domain is set up to use Gmail (all MX records are Google's MX records). Google's instructions say to include ~all in the SPF record. Do I need mx in this case?

Which is correct:

v=spf1 a ip4:111.222.333.0/24 ~all


v=spf1 mx a ip4:111.222.333.0/24 ~all


share|improve this question

migrated from Oct 12 '11 at 14:35

This question came from our site for professional and enthusiast programmers.

The first is correct for testing. The second is unnecessary because of the Google include.

When you're done testing (send an e-mail from all authorized servers to a test service) change the "~all" to "-all". The tilde indicates that you're testing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.