Activities

July 2010
M T W T F S S
« Jun   Aug »
 1234
567891011
12131415161718
19202122232425
262728293031  

My php mails are moving to spam box in Gmail

One of my client has spam issue with his server. Initial it was the problem with the sever IP reputation.

Possible reasons are,

1. Neighborhood ip on the same network was listed in the RBL black list. I have contacted hosting company to do the needful to solve the issue. They inform me that their ‘abuse team will take care of that.
2. All the major SMTP vendors are black listed our ips since it has been in the black list. Thus all the mails from my server moves directly to spam box. So that I need to contact the each vendors and fill out an online submission reg. this.

1. Yahoo
http://help.yahoo.com/l/us/yahoo/mail/postmaster/defer.html

2. For Hotmail/MSN
https://support.msn.com/eform.aspx?productKey=edfsmsbl&ct=eformts&wa=wsignin1.0&st=1&wfxredirect=1

After 3-5 days later, all my yahoo and hotmails are reached the proper place. But Gmail still having issues and my Googling would not help me to find a solution.

For further research I found that whenever I sent email from the web mail interface, it’s correctly reaching INBOX but not programmaticaly. I suspect issue is with the function we used to send mail or the parameter mentioned and developers are tried many ways, even spent a day. Evening I’m starting some research and googling to find a way to send a mail. Actually I do not know anything about php.

I have double checked the parameter used and ensure that mails are properly formatted. Again I got the mail in spam box.

After 2 or more testing, I got a mail in Gmail inbox, the way to hope.

The reason is that I thinking is,
WHM/Cpanel wouldn’t allow to impersonate the emails without been used any authentication or not permit to email from the non-existent email id on the same domain.

Suppose, I have an email id “matt@mydomain” and I need to send email from the non-existent id of ‘support@mydomain.com’. That mail definitely move to spam box in Gmail. I have enabled DKIM’ on the server at the same time.

The following piece of code helped me to send an authenticated mail.

<?php
require_once "Mail.php";

$from = "Mathew <admin@domain.com>";
$to = "Gmail user <user@gmail.com>";
$subject = "Welcome!";
$body = "User ,nnYou have recently registered US";

$host = "mail.domain.com";
$username = "matt@domain.com";
$password = "pass";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>

Now All is Well 🙂

The following link will e helpful for checking spam possibility,

1. Checking the ip is being blacklisted.
a.

http://www.dnsbl.info/dnsbl-database-check.php

b.

http://www.mxtoolbox.com/blacklists.aspx

2. Checking the RDNS ( Reverse DNS lookup)
a. From linux #host < my ip >
[root@host.sportu.com] test >>

host 209.85.225.18

18.225.85.209.in-addr.arpa domain name pointer iy-in-f18.1e100.net.
Check the ip is returning a dns entry to that ip

3. Checking SPF and DKIM ( domain keys)
a.

 http://www.mxtoolbox.com/spf.aspx

b.

http://www.kitterman.com/spf/validate.html

4. Is our server an Open relay
a.

http://verify.abuse.net/cgi-bin/relaytest

b.

 www.checkor.com/

c.

www.mailradar.com/openrelay/

How to check open relay

[root@web-test1 ~]# telnet mydomain.com 25
Trying 63.165.1.57...
Connected to mydomain.com (63.15.1.7).
Escape character is '^]'.
220 host.mydomain.com ESMTP Postfix
ehlo localhost
250-host.mydomain.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: tom@test.com
250 2.1.0 Ok
rcpt to: liju@office.com
<strong>554 5.7.1 <liju@office.com>: Relay access denied</strong>

It's shows our server is safe

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>