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 email1@gmail.com :email2@gmail.com
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
?
msg.setRecipients()
将地址数组作为第二个参数。
Use Message's subclass - MimeMessage. It implments the setRecipients(Message.RecipientType type, Address[] addresses)
method.
Furthermore, you could choose which specific message you need to use: IMAPMessage, POP3Message, SMTPMessage
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.