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 main.cf?


6 Answers 6


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.


I suspect your server is on a blacklist: http://www.dnsblcheck.co.uk/

  • +1, Also, could be a consumer connection, which is blacklisted by many servers (including all of ones I control).
    – Chris S
    Jul 6, 2010 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:

From: bob-mailer@alpha.bobs-servers.com

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.


For Batter Inbox delivery first of all configure and check you mail server configuration specially SPF and DKIM configuration. SPF Configuration: visit: openspf.net DKIM Configuration For Postfix in Ubuntu: https://help.ubuntu.com/community/Postfix/DKIM Testing of DKIM and SPF: http://www.port25.com/domainkeys/

After server configuration and testing please check you ip plack listing and sender score: Ip Blacklisting: mxtoolbox.com/blacklists.aspx Ip Reputation: senderscore.com (used by Yahoo and Aol), commtouch.com (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.


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 :-)


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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