Home
Tuesday, May 30, 2017
8:43:23 AM
Users online: 0   You are here >> Home > Programming

Forums | Programming Forums search
Forum FAQ
   
  1  
[PHP] RCPT failing - Works in telnet...
Invention 
7/8/08 6:02:33 PM
Primarch

I've got a script which does email verification by connecting to the domain's mx server. The script in a nutshell:
 
$connect = @fsockopen($connectaddress, 25)
if($connect){
if(ereg("^220, $out = fgets($connect, 1024))){
fputs ($connect , "HELO $HTTP_HOST\r\n");
$out = fgets ($connect, 1024);
fputs ($connect , "MAIL FROM: $fromemail\r\n");
$from = fgets ($connect, 1024);
fputs ($connect , "RCPT TO: $toemail\r\n");
$to = fgets ($connect, 1024);
fputs ($connect , "QUIT");
fclose($connect);
if(!ereg("^250", $from) || !ereg("^250", $to))
return "The email address does not exist";
}
}


So basically, I open a socket, sent a HELO, then send MAIL FROM and RCPT TO and capture the return, which I check for code 250 (OK). If it does not return OK then the address is deemed invalid.

The problem is that I'm finding its rejecting valid email addresses. The RCPT TO call is returning 550 - Blocked on email addresses that I know are valid. If I perform the same procedure via telnet, I get 220 returning from the RCPT call.

Any ideas ?

-----

Redhatter 
10/8/08 6:21:42 PM
Hero
Titan


Is this running telnet from the server executing the PHP script? Or from your desktop?

Also, have you tried just \r rather than \r\n? Maybe you're adding a linefeed the server isn't expecting.

-----
Stuart Longland (aka. Redhatter, VK4FSJL)
I haven't lost my mind it's backed up on a tape somewhere...
http://atomicdoc.yi.org <-- AtomicDOC Wiki
Resident Coolie-hatted Gentoo geek. (Gentoo MIPS & Mozilla herd member)

eckythump 
12/8/08 12:27:13 AM
Overlord

Not sure here, either, I would try what Redhatter suggested.

It should also be noted, though:

MAIL FROM: me@mydoman.com

BAD!

It should be:

MAIL FROM: <me@mydomain.com>

And the same applies to RCPT TO:

Some mailservers will not play nicely if you don't do this.

... and in 5 minutes, mine will be some of them. Thought I'd already turned on that standards-anal setting already.

-----
"Grandfather had an accident, he got burnt." "Oh no, how bad?" "Well, they don't fuck around at the crematorium."

Invention 
13/8/08 1:44:12 PM
Primarch

Redhatter: Same server. And I've since tried all combinations of newline/return characters with no luck. It either has the same issue, or it fails to connect completely.

eckythump: I've tried it with and without the < & > with no effect.

-----

  1  
Forums | Programming