InternetAddress.Parse is going to be your friend! See the worked example below:
String to = "[email protected], [email protected], [email protected]";
String toCommaAndSpaces = "[email protected] [email protected], [email protected]";
If strict is true, many (but not all) of the RFC822 syntax rules for emails are enforced.
msg.setRecipients(Message.RecipientType.CC,
InternetAddress.parse(to, true));
Parse comma/space-separated list. Cut some slack. We allow spaces seperated list as well, plus invalid email formats.
msg.setRecipients(Message.RecipientType.BCC,
InternetAddress.parse(toCommaAndSpaces, false));