Got the validation part covered.
Just looking to parse emails into their components.
Assuming an email is valid...
Can I just look backward for the first "@" and everything after that is the domain?
And then look backward for a space and everything after that is the email address minus the quoted name?
Why parse it yourself (and risk getting it wrong), when the work has already been done?
The Mime4j library (http://james.apache.org/mime4j/) includes (among many other things related to processing email) an
AddressBuilderclass that has methods for parsing email addresses (including groups and individual mailboxes, as well as address lists as they may appear in an email header) out into objects that represent them (instances of theAddressclass and its subclasses,GroupandMailbox). The returned objects have methods that provide access to the individual components of each address (local part, domain, human-readable name, etc.).The Javadoc for the
AddressBuilderclass can be found here: http://james.apache.org/mime4j/apidocs/org/apache/james/mime4j/field/address/AddressBuilder.html .