article

Check e-mail address validity(SMTP)

Email
Submitted on: 1/1/2015 10:12:00 AM
By: Bogomil Shopov (from psc cd)  
Level: Intermediate
User Rating: By 5 Users
Compatibility: PHP 4.0
Views: 2121
 
     In my work I am asking my self is there way to check e-mail address validity.Here is one oh the decisions...

 
				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)




Other 6 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.