我可以使用JavaMail API将邮件发送到Gmail,Hotmail等多个主机
换句话说,我可以发送InternetAddress的数组" TOList"或" CcList"这个数组包含不同的主机?提前致谢 。
答案 0 :(得分:1)
您可以多次拨打addRecipient
以将收件人添加到您的电子邮箱中。例如:
msg.addRecipient(Message.RecipientType.TO, InternetAddress.parse("user1@server1.com"));
msg.addRecipient(Message.RecipientType.CC, InternetAddress.parse("user2@server2.com"));
msg.addRecipient(Message.RecipientType.BCC, InternetAddress.parse("user3@server3.com"));
要发送数组,您可以执行以下操作:
Address[] ccRecipients = new Address[] {InternetAddress.parse("user1@server1.com"),
InternetAddress.parse("user2@server2.com")};
msg.addRecipients(Message.RecipientType.CC, ccRecipients);