InternetAddress validation
1 posts in topic
Flat View  Flat View

Posted By:   Roman_Schloemmer
Posted On:   Monday, July 29, 2002 03:19 AM

In the following code I try to parse a user entered eMail address. Somehow no AddressException is thrown when I enter an address like foobar.com. According to RFC822 I think the address must contain an "@". What can I do to force the user to enter an address like foo@bar.com?

addr = "foobar.com";
InternetAddress iAddress = new InternetAddress(addr);
}catch(AddressException ex){
System.out.pritnln("Exception: " + ex);

Re: InternetAddress validation

Posted By:   Christopher_Koenigsberg  
Posted On:   Monday, July 29, 2002 06:37 AM

Maybe it is taking "foo" as the localpart, assuming your local domain will be added by the local mail system e.g. it will be turned into "foo@yourdomain.com" (equivalently, taking "foobar.com" and assuming it will be turned into "foobar.com@yourdomain.com").

The local MTA (e.g. Sendmail or whatever) can be configured to accept bare localparts (e.g. "foo") in rfc822 address headers (e.g. "From:", "Reply-To:", "To:", "Cc:", "Bcc:"), and assume it will be constructing the rfc821 envelope addresses from them (e.g. the "MAIL FROM" and "RCPT TO" and DSN's) and that consequently it should append the local domain to them (e.g. "foo@yourdomain.com"). Or (better) it can be configured to require domains on addresses, in which case it (the local MTA) will reject the message submission.

About | Sitemap | Contact