From the JavaMail API:
Parse the given sequence of addresses into InternetAddress objects. If strict is false, simple email addresses separated by spaces are also allowed. If strict is true, many (but not all) of the RFC822 syntax rules are enforced. In particular, even if strict is true, addresses composed of simple names (with no "@domain" part) are allowed. Such "illegal" addresses are not uncommon in real messages.
Non-strict parsing is typically used when parsing a list of mail addresses entered by a human. Strict parsing is typically used when parsing address headers in mail messages.
I would say that you method
might work
sometimes. A better method would be to use a Regular Expression somewhere between getting the email address and handing it to the JavaMail API. That way you ensure that all the addresses are correct as soon as possible.
Here is Sun's tutorial on RE's. If you have other RE questions the
Java In General (Intermediate) is the most appropriate forum for those.
Here is a recent post on that very topic.
[ July 01, 2004: Message edited by: Gregg Bolinger ]