Jump to content
Sign in to follow this  
Guest harsh4u89

How to verify that a given email id exists or not.

Recommended Posts

Guest harsh4u89

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

Share this post


Link to post
Share on other sites

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.

Edited by trevelluk

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...