Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Email Address Validation

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I'm using SMTP in my java class to send mail. I need to verify/validate the email address entered by the user before sending a mail to that address.

Is there any way to validate the address which is out of the domain where my SMTP server exists?

Please help me ASAP...Thanks in advance
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am not sure if you found and answer...

Do you want to know if the address is well formed or the domain of the address is valid, i.e. exists, has an MX record, etc.?
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a PERL script to check and parse DNS records. It would be great to know how to do that directly with Java. Maybe some naming class or some method in the URL tools.
 
Rashid Mayes
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the DnsContextFactory to perform MX lookups. If you search for DnsContextFactory on java.sun.com you will find some pretty good examples. Start there. In the meantime here is a quick example of getting select records for an IP.




The NetworkInterface and InetAddress classes are usefull also. Look at the methods

InetAddress.getAllByName()
InetAddress.getByName()
InetAddress.isReachable()


Last but not least, you can use sockets to perfom whois lookups directly.
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok here is a quick and dirty validator. Gets the email string, validates it. If ok it returns the email if DNS lookup fails returns "<< email >>". Thus resetting the field. This is an AJAX call on the server so it isn't a real validator per see ala JSF or JSP style.



 
Have you no shame? Have you no decency? Have you no tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic