title: SPF for subdomain to avoid email spam
body: <p>SPF is a powerful method to avoid blocking the emails as spam. However, setup of SPF is normally for the main domain, and I was unable to find setting for subdomain, and I am not sure if it is effective at all. I want to setup my email server on <code>mail.domain.com</code> on a separate server. The SPF for the main domain is</p>
  
  <pre><code>@                 v=spf1 mx include:domain.com ~all
  @                 v=spf1 a mx ptr ip4:0.0.0.0 ~all
  </code></pre>
  
  <p>And for mail server (subdomain)</p>
  
  <pre><code>mail.domain.com   v=spf1 mx include:mail.domain.com ~all
  mail.domain.com   v=spf1 a mx ptr ip4:1.1.1.1 ~all
  </code></pre>
  
  <p>where 0.0.0.0 is the main server IP and 1.1.1.1 is the mail server IP. Will this setting work to successfully use mail.domain.com for emails (e.g. name@mail.domain.com)?</p>
  
  <p>What other considerations can help to avoid labeling the emails sent from subdomain as spam?</p>