【发布时间】:2013-12-22 13:18:41
【问题描述】:
我正在尝试使用 to、cc 和 bcc 发送邮件。我正在使用 javax.mail 来实现这一点。请在下面找到我的代码的一部分
InternetAddress[] myToList = InternetAddress.parse("gopi.mani@xyz.com,Maimsa.SF@xyz.com");
InternetAddress[] myBccList = InternetAddress.parse("Usha.B@xyz.com");
InternetAddress[] myCcList = InternetAddress.parse("NEHA.SIVA@xyz.com");
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(objEmail.getFrom()));
message.setRecipients(Message.RecipientType.TO,myToList);
message.setRecipients(Message.RecipientType.BCC,myBccList);
message.setRecipients(Message.RecipientType.CC,myCcList);
但是当我尝试执行这段代码时,我得到了以下异常:
javax.mail.SendFailedException:无效地址;
嵌套异常是:
com.sun.mail.smtp.SMTPAddressFailedException: 452 4.5.3 收件人太多
【问题讨论】:
-
属性设置了吗?
-
"452 4.5.3 Too many recipients" 让我相信 SMTP 服务器拒绝了您的电子邮件,而不是 Java 问题。您是否尝试过仅使用一个收件人来查看您是否继续收到此错误?
-
是的,我已经设置了如下属性,Properties props = new Properties(); props.put("mail.smtp.auth", "false"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", host_name); props.put("mail.smtp.port", 端口);
-
嗨史蒂文,如果我使用“message.setRecipients(Message.RecipientType.TO,myToList);”单独删除“BCC”和“CC”行代码。我的代码工作正常。请确认这仍然是 Java 问题还是 SMTP 服务器的问题
-
@user2928305:该错误消息直接来自 SMTP 服务器。
标签: java email bcc carbon-copy