I am trying to send multiple mails using JAVA Mail -
When I add a single Recipient -
message.addRecipient(Message.RecipientType.TO, new InternetAddress(“abc@xyz.com”));
It works fine, but not when I add multiple email addresses -
Here is the code
message.addRecipient(Message.RecipientType.TO, new InternetAddress(“abc@xyz.com”));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(“def@xyz.com"));
message.addRecipient(Message.RecipientType.CC, new InternetAddress(“ghi@xyz.com"));
message.addRecipient(Message.RecipientType.CC, new InternetAddress(“jkl@xyz.com"));
message.addRecipient(Message.RecipientType.BCC, new InternetAddress(“mno@xyz.com"));
The mail is sent and received, but when I check the email of abc@xyz.com
I can't see that the email has also been sent to def@xyz.com
or vise versa. Neither I can see CC in the list.
Mail details from abc@xyz.com
from: xyz@xyz.com
to: abc@xyz.com
date: Thu, Sep 8, 2016 at 4:38 PM
subject: Test
Mail details from def@xyz.com
from: xyz@xyz.com
to: def@xyz.com
date: Thu, Sep 8, 2016 at 4:38 PM
subject: Test
Mail details from ghi@xyz.com
from: xyz@xyz.com
to: ghi@xyz.com
date: Thu, Sep 8, 2016 at 4:38 PM
subject: Test
Mail details from jkl@xyz.com
from: xyz@xyz.com
to: jkl@xyz.com
date: Thu, Sep 8, 2016 at 4:38 PM
subject: Test
I tried changing the logic a little, but same result -
message.addRecipients(Message.RecipientType.TO, InternetAddress.parse(“abc@xyz.com, def@xyz.com"));
message.addRecipient(Message.RecipientType.CC, InternetAddress.parse(“ghi@xyz.com, jkl@xyz.com”));
message.addRecipient(Message.RecipientType.BCC, InternetAddress.parse(“mno@xyz.com"));
I am expecting to see the details as -
from: xyz@xyz.com
to: abc@xyz.com, def@xyz.com
cc: ghi@xyz.com, jkl@xyz.com
date: Thu, Sep 8, 2016 at 4:38 PM
subject: Test