java mail群发邮件问题
最近在修改一个群发邮件功能,老是报javax.mail.MessagingException: [EOF]
at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1363)
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1085)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
at javax.mail.Transport.send0(Transport.java:169)
at javax.mail.Transport.send(Transport.java:98)
at com.longtuo.common.mail.HtmlMailImpl.send(HtmlMailImpl.java:162)
at com.enjoy.server.bo.email.MessageServiceImpl.sendMail(MessageServiceImpl.java:57)
at com.enjoy.server.bo.email.MessageServiceImpl$1.send(MessageServiceImpl.java:79)
at com.longtuo.common.mail.MailWorker.run(MailWorker.java:53)
at java.lang.Thread.run(Thread.java:619)
这样的错,代码如下
public void send(String smtp, final String userId, final String passwd) throws AppException {
try {
// 获得邮件会话对象
init(smtp, "true");
// 验证
Authenticator auth = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userId, passwd);
}
};
mailSession = defaultInstance ? Session.getDefaultInstance(props, auth) : Session.getInstance(props, auth);
// 创建MIME邮件对象
mimeMsg = new MimeMessage(mailSession);
// 设置发信人
String from = this.from != null ? this.from : userId;
Address adress = fromText != null ? new InternetAddress(from, fromText) : new InternetAddress(from);
mimeMsg.setFrom(adress);
// 设置收信人
if (toAddress != null) {
mimeMsg.setRecipients(RecipientType.TO, InternetAddress.parse(toAddress.toString()));
} else if (to != null) {
mimeMsg.setRecipients(RecipientType.TO, InternetAddress.parse(to));
}
if (cc != null) {
mimeMsg.setRecipients(RecipientType.CC, InternetAddress.parse(cc));
}
// 设置暗送人
if(bccAddress!=null){
mimeMsg.setRecipients(RecipientType.BCC, InternetAddress.parse(bccAddress.toString()));
}else if (bcc != null) {
mimeMsg.setRecipients(RecipientType.BCC, InternetAddress.parse(bcc));
}
// 设置邮件主题
mimeMsg.setSubject(subject, encoding);
// 设置邮件内容
String mimeType = this.mimeType;
if (mimeType == null) {
mimeType = "text/html;charset=" + encoding;
}
if (multipart != null) {
// Multipart multipart = new MimeMultipart();
// BodyPart messageBodyPart = new MimeBodyPart();
// messageBodyPart.setContent(body, mimeType);//用html形式来发送内容
mimeMsg.setContent(multipart);
} else {
mimeMsg.setContent(body, mimeType);
}
// 发送邮件
Transport.send(mimeMsg); } catch (Exception e) {
log.error("邮件发送失败!", e);
throw new AppException("邮件发送失败!", e);
}
每次到红色代码处就报错,是不是一次发送的人太多了,一次性最多能发多少?求大神赐教 Java 邮件
补充:Java , Java相关