Guest harsh4u89 Posted September 7, 2010 Share Posted September 7, 2010 I am creating a web application in J2EE in which I take the email Id from the users. But sometimes the email id provided is not correct. (May be due to some mistake on the part of the user or user entering a fake email id)Hoe to check whether a given mail id is valid or invalidEg. some email id xyz@abc.comHow to check whether this is a valid mail id without sending mail to this mail id Link to comment Share on other sites More sharing options...
trevelluk Posted September 7, 2010 Share Posted September 7, 2010 Generally, you can't.You can check whether it is a syntactically valid email address, but without actually sending an email and waiting for some sort of response, you can't tell whether the address actually exists and can receive email.Also, its worth bearing in mind that even checking for a syntactically valid email address is more complex than you might expect (did you know email address can technically contain spaces and other special characters under certain conditions? I didn't until recently!)As its a Java / J2EE application, I'll mention that it might be useful to use the JavaMail API (http://www.oracle.com/technetwork/java/index-jsp-139225.html), specifically the javax.mail.internet.InternetAddress class, which throws an exception if its constructor is passed a syntactically invalid email address. Link to comment Share on other sites More sharing options...
Synook Posted September 7, 2010 Share Posted September 7, 2010 You can do a domain lookup on the host portion of the email address to see whether that domain exists... but you can't check whether the mailbox actually exists on the host. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.