Check e-mail address validity(SMTP)

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: 2425
     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 ESMTP
(User) helo localhost
(Server) 250
(User) mail from:admin<>
(Server) 250 ok
(User) rcpt to:contest<>
(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

Then let's look over the following lines:

(Server) 220 ESMTP Sendmail 8.11.6/8.11.6; Tue, 23 Apr 2002 13:43:10 +
helo localhost
(Server) 250 Hello [], pleased to meet you
(User) mail
(Server) 250 2.1.0 Sender ok
(User) rcpt
(Server) 550 5.1.1 User unknown

If web server support the user recognition, the result should be 'User unknown'

PHP implementation

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";

echo"The address is not valid";


$m=new CEmail;

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.