Check e-mail address validity
In my work I am asking my self is there way to
check e-mail address validity.Let's look over the following lines:
This is simple communication between user and SMTP server:
(Server) 220 server5.donhost.co.uk ESMTP
(User) helo localhost
(Server) 250 server5.donhost.co.uk
(User) mail from:admin<admin@purplerain.org>
(Server) 250 ok
(User) rcpt to:contest<contest@purplerain.org>
(Server) 250 ok
(User) data
(Server) 354 go ahead
(User) subject:this is a test
(User) hello friend how are you?
.
(Server) 250 ok 1019555935 qp 93990
(User) quit
(Server) 221 server5.donhost.co.uk
Then let's look over the following lines:
(Server) 220 astral.acvilon.com ESMTP Sendmail
8.11.6/8.11.6; Tue, 23 Apr 2002 13:43:10 +
0300
helo localhost
(Server) 250 astral.acvilon.com Hello [195.24.48.45], pleased to meet you
(User) mail from:htr@acvilon.com
(Server) 250 2.1.0 htr@acvilon.com... Sender ok
(User) rcpt to:bla_bla@acvilon.com
(Server) 550 5.1.1 bla_bla@acvilon.com... User unknown
If web server support the user recognition, the result should be 'User unknown'
PHP implementation
<?PHP
class CEmail{
function check($host,$user){
$fp = fsockopen ($host, 25);
set_socket_blocking ($fp, true);
fputs ($fp, "Helo Local\n");
fgets ($fp, 2000);
fgets ($fp, 2000);
fputs ($fp, "Mail From:<$user@$host> \n");
fgets ($fp, 2000);
fputs ($fp, "RCPT to:aetos<$user@$host> \n");
$result= fgets ($fp, 2000);
$st= substr($result,0,3);
if ($st==250){
echo"Email address is valid";
}
else
echo"The address is not valid";
}
}
$m=new CEmail;
$m->check("acvilon.com","farkon");
?>
This class implementing the conversation in previous chapter (SMTP & USER)
|