work,asking,self,there,check,email,address,va
Quick Search for:  in language:    
work,asking,self,there,check,email,address,va
   Code/Articles ╗ |  Newest/Best ╗ |  Community ╗ |  Jobs ╗ |  Other ╗ |  Goto ╗ | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
PHP Stats

 Code: 70,666 lines
 Jobs: 14 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for PHP.
rNews
By Van Baelen Sebastiaan on 8/18


Click here to see a screenshot of this code!phpNN Neural Networks
By Joachim Krebs on 8/17

(Screen Shot)

iif() function
By Martin C. Conniffe on 8/16


Dynamic List of Specified Files
By nothing34543534 on 8/15


Active Users (No MySQL) UPDATED! BETTER!
By Brandon Sachs on 8/15


PassGen v 1 stable
By Bogomil Shopov on 8/15


toString v 1.0 b
By Bogomil Shopov on 8/15


Calculating factorials
By Daniel Destro do Carmo on 8/14


AcidicChip's MP3 ID3v2 Tag Writer 1.0
By Chance O. One on 8/14


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Check e-mail address validity(SMTP)

Print
Email
 

Submitted on: 4/23/2002 7:08:22 AM
By: Bogomil Shopov  
Level: Intermediate
User Rating: By 1 Users
Compatibility:PHP 4.0

Users have accessed this article 5809 times.
 

(About the author)
 
     In my work I am asking my self is there way to check e-mail address validity.Here is one oh the decisions...

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
1) You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
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 13 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
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
4/24/2002 8:59:47 AM:Luis Cantero
When you connect to your local SMTP server, say yahoo.com and want to send an email to a hotmail user, your yahoo SMTP server will not know if the hotmail user exists or not. You talk about support for
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/24/2002 9:00:30 AM:Luis Cantero
You talk about support for "user recognition", this is only supported by the recipient's incoming SMTP server. So in order for your checking program to work, you will need to check the MX record of the recipient's server by querying a DNS server, once you get the incoming SMTP server for the recipient, you can implement the check as you described above.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/26/2002 10:51:44 AM:Krishna
The above given (Server), (User) communication fails in most of the cases ie the server will not return mail error if the rcpt to:<?????> does not exist. If you give some junk mail id for the rcpt to: field, most of the servers accept it as Reciepent OK.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/27/2002 2:30:30 AM:Saurabh
Krishna, in most cases this will NOT fail as long as you are connecting to the receipient's mail exchange (MX) server and not your local SMTP server. Because your SMTP server can't say if a user exists on the other domain or not.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/27/2002 2:34:55 AM:Saurabh Gupta
FYI, you can find out the MX server for a domain using a small app that I wrote. You can see it at: http://www.planet-source-code.com/v b/scripts/ShowCode.asp?txtCodeId=34016&l ngWId=1
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/6/2002 5:09:24 AM:chetan
kindly suggest the smtp code using perl or VB for sending mails from my PC. I use Win 98 as server and I dont have a static IP. Em comando_c@yahoo.com
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/6/2002 5:14:51 AM:CHETAN
kindly suggest the smtp code using perl or VB for sending mails from my PC. I use Win 98 as server and I dont have a static IP.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/5/2002 9:37:12 PM:Steve Belanger
There was an error in the code of the function that checks the email. I would recommend use socket_set_blocking instead of set_socket_blocking as that funciton is not defined in the php reference. Regards. Steve Belanger.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this article has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular article, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | PHP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyrightę 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.