I ended up waiting to add the cc until right before setting it in the mimehelper, whereas before I was setting it in a message header, which was messing things up. Never figured out why.
Spring MimeMessageHelper: AddressException when adding multiple CC
-
27-11-2021 - |
Вопрос
I need to add multiple CC addresses to my mail message, but I keep getting the following exception:
javax.mail.internet.AddressException: Illegal Address (email@email.com;email@email.com,15)
Here is my code:
final String ccAddress = (String) inputMessageHeaders.get(MailHeaders.CC);
final String[] arrayOfCCAddress = ccAddress.split(";");
for(String cc : arrayOfCCAddress) {
InternetAddress address = new InternetAddress(cc);
mimeMessageHelper.setCc(address);
}
The original value of ccAddress is "email@email.com;email@email.com" The actual addresses are valid. Why is it throwing an exception and adding the ",15" to the end of the CC address?
Thanks
Решение
Не связан с StackOverflow