Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using javax.mail to send to multiple recipients

I've got the following...

msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));

Which works fine but when I attempt to add this multiple times (with different variables for to) it only sends to the last statement. I've also attempted sending something like [email protected] :[email protected] as the to variable but this throws back an error.

Does anyone have any suggestions as to how I'd send mail to multiple recipients using JUST one e-mail and not multiple e-mails using javax.mail?

like image 924
Skizit Avatar asked Jan 22 '23 00:01

Skizit


1 Answers

msg.setRecipients() takes an array of addresses as the second parameter.

like image 172
highlycaffeinated Avatar answered Jan 30 '23 19:01

highlycaffeinated