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 want to start an indepth discussion on all ways of avoiding mail being flagged as spam. I have done most of what i knew to prevent mail from being listed as spam. i have tried the following

1) using phpmailer to setup appropriate headers 2) used SPF correctly 3) implemented DKIM correctly 4) my sender score is 93

I have even gone as far as asking hotmail etc to add me to a permited sender policy.

all these have been all in vain. below is a header i get from my gmail account. and the mail is still flagged as spam.

Received: by with SMTP id l15cs5000vca;
        Wed, 26 Oct 2011 05:33:28 -0700 (PDT)
Received: by with SMTP id o2mr18662906ict.0.1319632407924;
        Wed, 26 Oct 2011 05:33:27 -0700 (PDT)
Return-Path: <>
Received: from ( [])
        by with ESMTP id x1si830537icv.118.2011.;
        Wed, 26 Oct 2011 05:33:27 -0700 (PDT)
Received-SPF: pass ( domain of designates as permitted sender) client-ip=;
Authentication-Results:; spf=pass ( domain of designates as permitted sender); dkim=pass
Received: from (localhost [])
    by (Postfix) with ESMTP id 90FC6164356
    for <>; Wed, 26 Oct 2011 12:33:27 +0000 (UTC)
X-DKIM: OpenDKIM Filter v2.4.1 90FC6164356
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;;
    s=default; t=1319632407;
Received: (from apache@localhost)
    by (8.13.8/8.13.8/Submit) id p9QCXRHt031452;
    Wed, 26 Oct 2011 12:33:27 GMT
To: Hassan Hussein <>
Subject: Hassan Hussein?, You've got unseen alerts pending
Date: Wed, 26 Oct 2011 12:33:27 +0000
From: Veepiz Alert <>
Reply-to: Veepiz Alert <>
Message-ID: <1b841dbd639524b970b9adcf77a08704@localhost.localdomain>
X-Priority: 3
X-Mailer: PHPMailer 5.1 (
MIME-Version: 1.0
Content-Type: multipart/alternative;

Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

Dear Hassan Hussein,
 You have a total of 6 alert(s) at
These are listed below;

- 6 Unread Message(s).

Please visit and view these
unseen notifications.

Remember, to view your notifications, hover over
the yellow notifications icon on the menubar.

Thanks Management

Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

Dear Hassan Hussein,<br />
 You have a total of 6 alert(s) at <a href=''></a>. These are listed below;<br />
<br />
- 6 Unread Message(s).<br />
<br />
Please visit <a href=''></a> and view these unseen notifications.<br />
<br />
Remember, to view your notifications, hover over the yellow notifications icon on the menubar.<br />
<br />
Thanks Management

Forgotten your password? go to <a href=''></a>

share|improve this question
A) This isn't really a place for in-depth discussion. – Bart Silverstrim Oct 26 '11 at 13:02
B) You don't mention the content of the mail, which can significantly influence having messages flagged. – Bart Silverstrim Oct 26 '11 at 13:03
Then where are you seeing it get filtered as spam? At the email provider, or at your mail client? Are you getting your messages flagged at the actual clients, or just your system? – Bart Silverstrim Oct 26 '11 at 13:09
in actual client emails like if you check gmail... the emails reside in spam.ive just done a test here… – Sir Lojik Oct 26 '11 at 13:29
If it's happening in your mail client software (I mixed the definition above...client software, and I was asking about actual subscribers to your service as clients) then you may have to look at how it was trained to search for email. – Bart Silverstrim Oct 26 '11 at 13:36

If you've set up SPF and DKIM correctly, and there's a valid PTR (reverse DNS) record, that's about all you can do on your server. This has been discussed here before...

Prevent mail being marked as spam

Why are emails sent from my applications being marked as spam?

One thing that I don't think has been included in other questions about this has been what - if anything - can be done about client filtering.

Unfortunately, there's nothing you can do on a to guarantee that some client - e.g. Gmail in your posted sample - won't classify a message as SPAM. Looking in my Gmail Spam folder, I see some semi-legitimate messages with headers like yours that indicate SPF, etc. is fine, but they're filtered because I've marked similar messages as Spam.

Since you have no control over what email client recipients might be using and how those clients are configured, probably the only other step you could take would be to ask them to include your sending address in their address book or other whitelist. It's no guarantee, and it's not really possible to give general instructions on how they do it, but it might help a bit.

share|improve this answer
My Spam filter would trigger on the mail content. This doesn't really look like legitimate mail. The header, PTR, DKIM and SPF would confirm that this is Ham, but the content is really ... spammy. – mailq Oct 26 '11 at 20:22

If you look at your IP's reputation at, then you will notice that you had heavy outbreaks of mails (probably Spam) at the beginning of October. This may also have a big impact on the reputation at Google (currently).

Google probably doesn't use McAffee's database as a valid resource, but they have their own (secret) reputation system that will capture your overall traffic. And if they noticed a bad reputation in the past, it will take some time until they revalidate their findings and put your IP on "good reputation".

This is how Spam prevention works nowadays. It is not based on "this message" or "that message" but on your overall behavior. If the outbreak in October was a fault due to a malware infection then this is bad for you (even currently) but maybe disappear in the future.

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.