0

I was working for my college website, and I wrote a php script that sends email using php mail function. But the problem is, all the emails that I send are going into the recipients spam/junk Folder.

In order to resolve it, I tried all the steps and answers for the similar issues in stackoverflow and serverfault website, but yet the problem is unresolved.

This is the php code for sending email:

<?php
$from_address="webmaster@".$_SERVER['SERVER_NAME'];
$from_name="webmaster";
$headers = "MIME-Version: 1.0\r\n"
  ."Content-Type: text/plain; charset=utf-8\r\n"
  ."Content-Transfer-Encoding: 8bit\r\n"
  ."From: =?UTF-8?B?". base64_encode($from_name) ."?= <$from_address>\r\n"
  ."X-Mailer: PHP/". phpversion();
$subject="Web Mail Testing";
$body="This is test Message";
$to="[email protected]";
mail($to, $subject, $body, $headers, "-fwebmaster@{$_SERVER['SERVER_NAME']}");
echo "The Mail is  SuccessFully Sent to :".$to;
?>

I am also attaching the original email (that i received in my gmail account "[email protected]")

Delivered-To: [email protected]
Received: by 10.204.8.210 with SMTP id i18csp146000bki;
        Wed, 21 Nov 2012 20:58:12 -0800 (PST)
Received: by 10.68.219.164 with SMTP id pp4mr1119127pbc.72.1353560291776;
        Wed, 21 Nov 2012 20:58:11 -0800 (PST)
Return-Path: <[email protected]>
Received: from www.nitw.ac.in (www.nitw.ac.in. [218.248.13.200])
        by mx.google.com with ESMTPS id sh10si3456960pbb.293.2012.11.21.20.58.10
        (version=TLSv1/SSLv3 cipher=OTHER);
        Wed, 21 Nov 2012 20:58:11 -0800 (PST)
Received-SPF: pass (google.com: best guess record for domain of [email protected] designates 218.248.13.200 as permitted sender) client-ip=218.248.13.200;
Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of [email protected] designates 218.248.13.200 as permitted sender) [email protected]
Received: from www.nitw.ac.in (localhost.localdomain [127.0.0.1])
    by www.nitw.ac.in (8.13.8/8.13.8) with ESMTP id qAM50M0h016190
    for <[email protected]>; Thu, 22 Nov 2012 10:30:23 +0530
Received: (from nobody@localhost)
    by www.nitw.ac.in (8.13.8/8.13.8/Submit) id qAM50McG016189;
    Thu, 22 Nov 2012 10:30:22 +0530
Date: Thu, 22 Nov 2012 10:30:22 +0530
Message-Id: <[email protected]>
X-Authentication-Warning: www.nitw.ac.in: nobody set sender to [email protected] using -f
To: [email protected]
Subject: Web Mail Testing
X-PHP-Originating-Script: 0:mailer.php
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
From: =?UTF-8?B?d2VibWFzdGVy?= <[email protected]>
X-Mailer: PHP/5.3.5

This is test Message

Also while googling I found a reason for this sort of problem is server blacklisting, and I used this tool to test it.

I was shocked when the above tool test found my server in some blacklists. How this is the case, since the original mail that i attached above says ":Received-SPF: pass (google.com: best guess record for domain of [email protected] designates 218.248.13.200 as permitted sender)

Also, if my server is blacklisted, then how can i find the reason for blacklist and how to resolve it?

1 Answer 1

1

Regarding the spam/junk mail folder issues, two things:

  1. You need to look at the mail host's guidelines and help for bulk senders. Gmail's is here. Once you do everything they recommend, if your email's still getting marked as spam, ask them for help/support.

  2. Check your emails against a spam checker. There are free online tools available, you can run them against your spam filter of choice, etc., and work on getting the spam score as low as possible.

Regarding the blacklist:

  1. The tool you linked to checked against 45 different (relatively widely used) blacklists. Gmail does not use any of the 3 your server was blacklisted on.

  2. To get off a blacklist, you generally need to contact the organization that maintains it, plead your case, and get them to take you off. They'll also be the only ones able to tell you how you got on their specific blacklist.

    • The reasons for a mail server being blacklisted are usually either that enough people complained to them about emails coming from your server, or they discovered your server to be an open-relay, or otherwise possibly compromised by spammers.

    • There are people and businesses that will do the de-blacklisting work for you, usually for a very sizeable fee.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .