• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Email Address Validation

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic