0

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

Delivered-To: my_address@gmail.com
Received: by 10.227.117.6 with SMTP id o6csp468220wbq;
        Thu, 16 Aug 2012 00:21:15 -0700 (PDT)
Received: by 10.43.117.129 with SMTP id fm1mr196323icc.1.1345101675202;
        Thu, 16 Aug 2012 00:21:15 -0700 (PDT)
Return-Path: <bounce+95719fab75@my_smtp_server_domain.com>
Received: from mailapproved.com (mailapproved.com. [199.195.193.140])
        by mx.google.com with ESMTP id s18si1547632igi.61.2012.08.16.00.21.14;
        Thu, 16 Aug 2012 00:21:15 -0700 (PDT)
Received-SPF: pass (google.com: domain of bounce+95719fab75@my_smtp_server_domain.com designates 199.195.193.140 as permitted sender) client-ip=199.195.193.140;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of bounce+95719fab75@my_smtp_server_domain.com designates 199.195.193.140 as permitted sender) smtp.mail=bounce+95719fab75@my_smtp_server_domain.com; dkim=pass header.i=@mailapproved.com
Received: from ml.my_smtp_server_domain.com.com (ml.my_smtp_server_domain.com.com [199.195.193.133])
    by my_smtp_server_domain.com.com (Postfix) with ESMTPA id E3CC68E057
    for <my_address@gmail.com>; Thu, 16 Aug 2012 07:21:12 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=my_smtp_server_domain.com;
    s=server1; t=1345101672;
    bh=TsyHxri8hUJjEnMBm8JUJzfLs5a3ea9aRZQ15toMNyQ=;
    h=Date:To:From:Reply-to:Subject:List-Unsubscribe;
    b=hOUSOx/fN8ZwTlEp4KBAKSGRZHgH6kSj0xUeLlq8J2JGBEE2x6c2b5sh/nFwqx45T
     kuorzu3TsLDDMHCBLmSNLfrYWqyCzkT4Iwh1NJlCL5zm4GwYDXVrVsd+6AjJNfzPN+
     W5idEJ62+MCgsMqgCd6gmpACMcqntgwgp+WcLKFc=
Date: Thu, 16 Aug 2012 15:21:12 +0800
To: Me <my_address@gmail.com>
From: Someone <no-reply@my_smtp_server_domain.com>
Reply-to: No Reply <no-reply@my_smtp_server_domain.com>
Subject: Welcome to Blah
Message-ID: <f2039f590798697bc998c686920020df@ml.my_smtp_server_domain.com>
List-Unsubscribe: <mailto:unsubscribe@my_smtp_server_domain.com?subject=Unsubscribe>, <http://ml.my_smtp_server_domain.com.com/unsubscribe/e783daa664>
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_f2039f590798697bc998c686920020df"

There are two servers here: my_smtp_server_domain.com which is the SMTP server, and ml.my_smtp_server_domain.com 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?

1
1

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.

1

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 = 'from_email@domain.com';
$mail->Sender = 'sender_email@domain.com';
...

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.