phpmailer, php, header, email goes to spam

17,413

This is because when you send a mail with the PHP mail() function, if you are using a shared host, it will appear in your Received header. One way is to change your headers that you are sending. This article and this article give a good way to bypass spam filters by changing headers.

For best practices, you should investigate using the Sender Policy Framework (SPF) to avoid being regarded as spam.

You might also be interested in sendmail, which connects to another email account (say, a Gmail account) and sends mail from that account, not from your local server.

Share:
17,413
sniper
Author by

sniper

Updated on June 27, 2022

Comments

  • sniper
    sniper almost 2 years

    I am running into a problem while sending out emails from the system and the problem is that the email gets delivered to the spam box in gmail/yahoo/hotmail. I am posting here, after doing my bit of homework, and have already validated and checked the SPF settings, Reverse DNS settings(was pointing elsewhere, and made the change this morning about 5 hours ago). The RDNS check now says the mapping is perfect. Yet no luck. Mails are going to spambox. What could be the problem?

    Background : I use PHP with PHPMailer to send out emails.

    The header from the mail received in the spam box :

    Delivered-To: [email protected]
    Received: by 10.227.144.12 with SMTP id x12cs63931wbu;
        Mon, 9 May 2011 17:05:44 -0700 (PDT)
    Received: by 10.68.64.225 with SMTP id r1mr11349194pbs.250.1304985942785;
        Mon, 09 May 2011 17:05:42 -0700 (PDT)
    Return-Path: <[email protected]>
    Received: from xpal.com (208.78.241.38.svwh.net [208.78.241.38])
        by mx.google.com with ESMTPS id w1si21200467pbh.199.2011.05.09.17.05.40
        (version=TLSv1/SSLv3 cipher=OTHER);
        Mon, 09 May 2011 17:05:41 -0700 (PDT)
    Received-SPF: pass (google.com: domain of [email protected] designates 208.78.241.38 as permitted sender) client-ip=208.78.241.38;
    Authentication-Results: mx.google.com; spf=pass (google.com: domain of [email protected] designates 208.78.241.38 as permitted sender) [email protected]
    Received: by xpal.com (Postfix, from userid 33)
    id F31C12C30BA; Mon,  9 May 2011 17:05:29 -0700 (PDT)
    To: Ajith Ravi <[email protected]>
    Subject: checkarun replied on your xpalling on Sindura
    X-PHP-Originating-Script: 0:phpmailer_class.php
    Date: Mon, 9 May 2011 17:05:29 -0700
    From: XPal Members Alert <[email protected]>
    Reply-to: Xpal Members Alert <[email protected]>
    Message-ID: <[email protected]>
    X-Priority: 3
    X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)
    MIME-Version: 1.0
    Content-Type: multipart/alternative;
    boundary="b1_e773974b10a1d7a0e54d55f489427da1"
    
  • sniper
    sniper almost 13 years
    @mc10, Thanks!! Since I am using phpmailer to send, I sure am changing my headers. I did go through those articles and looks like I am doing most of it right. The server I am using is a dedicated server, so that may not be a problem. Updated header details : Received: from xpal.com (xpal.com [208.78.241.38]) by mx.google.com with ESMTPS id k2si21395354pbo.204.2011.05.09.18.38.54 (version=TLSv1/SSLv3 cipher=OTHER); What could the potential issue be?
  • sniper
    sniper almost 13 years
    Here is the snippet of the code I am setting inside the class function that sends out the emails : $mail = new phpmailer(); $mail->AddCustomHeader('Reply-to:[email protected]'); $mail->From="[email protected]"; $mail->FromName="XPal Members Alert";
  • sniper
    sniper almost 13 years
    Thanks Mel! I did go through that before I posted my question here. Looks like a header related issue, but I am just hoping that someone can see through something thats wrong in the header that I've shared! :)
  • kevinji
    kevinji almost 13 years
    Are you sending the mail from the XPal server? If not, then you may have issues with DKIM. You need to send a DKIM header as well for confirmation by mail agents.
  • sniper
    sniper almost 13 years
    Ahh, you have exactly touched my grey area. :) . Let me get my questions clarified. If I am using the sendmail available on the xpal server to send out the email(phpmailer class does this), does that necessarily mean that I am sending the mail out from the xpal server? If not, what happens after the sendmail program is activated? My domain key manager told me told me once that he has not added the mailserver IP of the hosting company to the TXT file. Could that be a reason? Thanks again! :)
  • kevinji
    kevinji almost 13 years
    Another issue: Your header contains 208.78.241.38.svwh.net [208.78.241.38], which contains your host's name.
  • kevinji
    kevinji almost 13 years
    So am I correct when you say that you actually send out the mail on the XPal server?
  • sniper
    sniper almost 13 years
    Oh I had updated the latest header in the first comment. Here it goes again : Received: from xpal.com (xpal.com [208.78.241.38]) by mx.google.com with ESMTPS id k2si21395354pbo.204.2011.05.09.18.38.54 (version=TLSv1/SSLv3 cipher=OTHER); The original Received: posted might have had svwh.net info because the RDNS settings could have been propagating still this afternoon :)
  • sniper
    sniper almost 13 years
    I guess I am sending the mails out on the XPal server(the phpmailer class, uses the default sendmail program on the server to send the email out)...
  • Kenny Cason
    Kenny Cason about 12 years
    I would say before reading that, ensure that all the headers for the mail are sent, then if you still can't get it start with that link. I have found most of my troubles have always been from things like bad header info, links in the title, or other little things like that.