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'm sending out emails using PHPMailer through an SMTP server that I control, and I have DKIM and SPF set up and working properly, however, when I send a test email to my gmail account it goes to the spam folder immediately and claims that my email is similar to messages detected by their spam filters.

However, if I then use Outlook to send the exact same message through the same SMTP server, it doesn't get filtered as spam.

These are the headers from an email that went to spam

Received: by with SMTP id o6csp468220wbq;
        Thu, 16 Aug 2012 00:21:15 -0700 (PDT)
Received: by with SMTP id fm1mr196323icc.1.1345101675202;
        Thu, 16 Aug 2012 00:21:15 -0700 (PDT)
Return-Path: <>
Received: from ( [])
        by with ESMTP id s18si1547632igi.61.2012.;
        Thu, 16 Aug 2012 00:21:15 -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 ( [])
    by (Postfix) with ESMTPA id E3CC68E057
    for <>; Thu, 16 Aug 2012 07:21:12 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;;
    s=server1; t=1345101672;
Date: Thu, 16 Aug 2012 15:21:12 +0800
To: Me <>
From: Someone <>
Reply-to: No Reply <>
Subject: Welcome to Blah
Message-ID: <>
List-Unsubscribe: <>, <>
MIME-Version: 1.0
Content-Type: multipart/alternative;

There are two servers here: which is the SMTP server, and which is a mailing app (for legit newsletters for people who have double OP'd in).

The message itself is just a simple confirmation email for a mailing list.

I don't understand how it can work when I use Outlook but fail with PHPmailer, what's different?

share|improve this question
PHPMailer is different. – Michael Hampton Aug 17 '12 at 3:22

The headers sent by Outlook and PHPMailer, or any other mailer, are different. Many spam filters will automatically increase a message's spam score when such headers are detected. This is presumably because they are so prevalent in spam.

As a first step remove any headers that identify the sending system as being PHPMailer. If that doesn't help then look at the message itself and try to modify it so that it looks less like spam, as your message may be riding the edge.

share|improve this answer

I was having the same problem using PHPMailer, and here's what fixed the problem for me: set the Sender (this is different and distinct from the "From") to a valid email account for the domain you are sending the email from. This causes PHPMailer to properly set the "envelope-from" information so that the email passes SPF and Sender-ID validation. Without doing this, the "envelope-from" is an OS level user id and server combination which will not be verifiable. I hope this helps.

Example Code:

$mail = new PHPMailer;

$mail->From = '';
$mail->Sender = '';
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.