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

I have a linux server, with postfix just installed.

I am new to email-servers...

Anyways, I am able to send mail with php:s mail function, but they are considered "spam" by google mail (and probably most other email accounts also, haven't tested hotmail, yahoo etc).

I am guessing it has something to do with SPF, but I don't have a clue what SPF is, how to fix it etc etc...

Can anybody explain how to make my emails "Non-spam" which they are not?

OS is Ubuntu 9.10.

If you need more input let me know...


PS: How can I disable all incoming mail to my postfix (email server) without using my firewall, maybe by using

share|improve this question
From Atwood blog:… – Vitor Py Jul 5 '10 at 17:45
look at… and… - those are very similar questions – pQd Jul 5 '10 at 18:42
This has been duplicated at… which has more answers than this one. Don't know if there's a way of merging, but certainly one of these should be closed. – kaerast Jul 5 '10 at 19:28
This is a duplicate of… though this one has more answers than the original. – kaerast Jul 5 '10 at 19:50
up vote 4 down vote accepted

Ok, there's 3 (very different things) you need to be doing to avoid false positives.

  1. Reverse DNS needs to be set-up, so the IP of your server resolves to your server's hostname. You need to ask your hosting provider/netblock owner to do this, you can't do it yourself directly.

  2. SPF. This involves adding an entry to the DNS zone record that your server is part of. It doesn't involve server configuration (unless it's also the nameserver for the domain). SPF generator may help here.

  3. Set-up DKIM on your server. Not too difficult, the dkim-filter package on Debain based systems IIRC, google for a tutorial.

You should also check that your domain and IP isn't on a block list somewhere. You need to google and read a lot as well - postmaster is no easy job.

Also have a look at MX Toolbox.

If you post your servers name, I can give further pointers.

share|improve this answer

I suspect your server is on a blacklist:

share|improve this answer
+1, Also, could be a consumer connection, which is blacklisted by many servers (including all of ones I control). – Chris S Jul 6 '10 at 2:29

One common trick for eliminating having your mail marked as spam is to always send mail using valid From: headers.

For example if your hostname is 'bobs-server' and you send a mail using the local mail command (which is what PHP's mail() function does, by default), it will appear to come from something like "apache@bobs-server".

Of course, on the open Internet, bobs-server isn't a real domain and attempts to look up A or MX records for this host will fail. You should give your server (or at least the external IP/NAT it comes from) a valid A record (and/or MX record if you want to accept mail) and then use a from header to match, such as:


This will eliminate a lot of hosts regarding your mail as insta-spam. SPF records haven't really been implemented fully on the Internet and aren't commonly used authoritatively for whether or not something is spam.

Hope that helps.

share|improve this answer

For Batter Inbox delivery first of all configure and check you mail server configuration specially SPF and DKIM configuration. SPF Configuration: visit: DKIM Configuration For Postfix in Ubuntu: Testing of DKIM and SPF:

After server configuration and testing please check you ip plack listing and sender score: Ip Blacklisting: Ip Reputation: (used by Yahoo and Aol), (Used by rediff)

After all this if you mail still found in spam then please check keywords of your email body. Check is your From address is valid.

share|improve this answer

I'm not a systems admin, so someone else can probably answer better :)

I know that some systems block mails without a reverse DNS entry for your MX record. Basically a method for looking up your servers ip address and match it the domain. Ask someone else about the details :-)

share|improve this answer

SPF has nothing to do with identifying spam, it's about identifying forged email senders.

There are a long list of potential reasons from the server being on a blacklist (RBL) to issues with the mail formatting or headers. I'd suggest you start with checking that the IP isn't in any RBL.

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.