Get the correct response from Yahoo SMTP
I try to send a mail via php to an yahoo recipient. Every time I connect to yahoo I get a 250 status code for the recipient address, even if it doesn't exist. I found a script which get the correct status code from yahoo, but I cannot find the differences or mistakes I did in my script. I tried to send different commands and run the script on several servers, but I always get a 250 response for the RCPT-TO-command. Why do I don't get the correct response? I want to stop my script when a recipient doesn't exist!
Log of verify-email.org which gets the correct response:
MX record about yahoo.com exists. Connection succeeded to g.mx.mail.yahoo.com SMTP. =220 mta1062.mail.sp2.yahoo.com ESMTP YSmtp service ready > HELO verify-email.org =250 mta1062.mail.sp2.yahoo.com > MAIL FROM: <check@verify-email.org> =250 sender <check@verify-email.org> ok > RCPT TO: <sdjrfvn3r@yahoo.com> =554 delivery error: dd This user doesn't have a yahoo.com account (sdjrfvn3r@yahoo.com) [0] - mta1062.mail.sp2.yahoo.com
Log of my script which gets the wrong response:
C Connect to h.mx.mail.yahoo.com S 220 mta1144.mail.mud.yahoo.com ESMTP YSmtp service ready C HELO my-domain.com S 250 mta1144.mail.mud.yahoo.com (152.70 ms) C MAIL FROM: <existing-address@my-domain.com> S 250 sender <existing-address@my-domain.com> ok (723.29 ms) C RCPT TO: <sdjrfvn3r@yahoo.com> S 250 recipient <sdjrfvn3r@yahoo.com> ok (152.67 ms) C Close socket connection S Connection closed gracefully
You can find the script which works properly here: http://verify-email.org
My script:
while(preg_match('/^\d\d\d-/', $r = fgets($sock))) {
$response .= $r;
}
$response .= $r;
return $response;
}
$mxRecord = "a.mx.mail.yahoo.com";
$domain = 'example.com';
$mailFrom = 'mailfrom@example.com';
$rcptTo = 'doesntexist2011@yahoo.com';
$commands = array(
"HELO ".$domain."\r\n",
"MAIL FROM: <".$mailFrom.">\r\n",
"RCPT TO: <".$rcptTo.">\r\n",
// "DATA\r\n",
// ... email subject and content
// ".\r\n",
"QUIT\r\n"
);
if($sock = fsockopen($mxRecord, 25, $errno, $errstr, 30)) {
foreach($array as $cmd) {
echo htmlentities($cmd);
echo '<br />';
fwrite($sock, $cmd);
echo htmlentities(getResponse($sock));
echo '<hr />';
}
fclose($sock);
}
else {
echo 'no connection';
}
?>
Some information:
- I used my own domain (not example.com)
- The script is located on the server where my domain refers to
- The server isn't on any blacklist like spamhaus.org
- The used mail address in "Mail From" does exist
- I use getmxrr() to get the mx entries of yahoo.com
- I tried HELO and EHLO -> always the sam开发者_StackOverflow中文版e response
Do NOT waste your money on verify-email.org. I had written a class that works quite well at verifying email addresses, but had been having problems for days trying to return anything from Yahoo other than a 250 Recipient OK message. I finally came up with a work around which I would share here by unfortunately after hitting their servers about 10 times or so they blocked me for 12 hours. I then moved the class from my dev server to a live server with a good domain name, rDNS configured and everything that would allow me to send emails without getting blacklisted minus domain keys. Again, I got nothing but 250 responses with SMTP and again I got my IP blocked with my work around. I finally decided to break down and buy the script to "see what they're doing different". The answer: They aren't doing anything different. In fact, the script was garbage and almost identical to any rudimentary script you can find online. I loaded it on 2 different server and with two different configurations, followed the directions of the script to the letter ( it was only 1 or 2 instructions) and yet, got the same 250 response for the exact same email address that I received a 554 on the site. Digging a little deeper I found that it was potentially an email marketing company selling the script. They either have a relationship with Yahoo and others or its calling some other backend system, i dont know but I do know the sccript does not work. Furthermore, an emails sent to the seller and SWREG (a digital river company) have gone unanswered as well as a request for a refund. I sent screenshots of my results versus what they display on the site. I am now filing a dispute with my Credit Card company. Point being, DO NOT BUY from verify-email.org. Its a scam. That is unless you feel like pissing away $45.
My only advice is to form business relationships with the majors or go through a company like ReturnPath (very very expensive.) Or, send confirmation emails to each subscriber. I unfortunately work for a marketing company that can't send confirmation emails based on rules they have with their affiliate partners so I have to use a third party service (expensive) or come up with another solution. Good luck.
Did you read the FAQ of verify-email.org? "For some domains you can't verify whether the address is good or not, because their mail servers don't cooperate. For example: yahoo.com"
This is because these mail servers don't want spammers harvesting known-good email addresses.
精彩评论