首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Java Mail发送邮件时出错

使用Java Mail发送邮件时出错
EN

Stack Overflow用户
提问于 2015-06-30 16:45:45
回答 1查看 1.6K关注 0票数 0

我在使用Java Mail发送邮件时遇到以下错误。下面是错误。你能告诉我错误的原因吗?

代码语言:javascript
复制
ERROR :: Sending failed;
  nested exception is:
    class javax.mail.SendFailedException: Invalid Addresses;
  nested exception is:
    class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
  nested exception is:
    class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
  nested exception is:
    class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
  nested exception is:
    class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
  nested exception is:
    class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
  nested exception is:
    class javax.mail.SendFailedException: 452 Too many recipients received this hour
;
  nested exception is:
    class javax.mail.SendFailedException: 452 Too many recipients received this hour

下面是导致异常的方法。

公共空sendTextReport(DataBean dataBean,TextBean textBean)抛出IOException,MessagingException {

代码语言:javascript
复制
    Session session = getAuthentication();


        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(this.props.getProperty("from")));
        message.addRecipients(Message.RecipientType.TO,InternetAddress.parse(this.props.getProperty("textTo")));
        message.addRecipients(Message.RecipientType.CC,InternetAddress.parse(this.props.getProperty("textCc")));

        message.setSubject(" Report for the submissions between "+ dates.getDate1() + " and " + dates.getDate2());

        StringBuilder mailBody = new StringBuilder();

        mailBody.append("<text>Hi All,<br><br>Below is the Report for the submissions </text><br><br><br>");
        mailBody.append("<table><tr><th>Description</th><th>Count</th></tr>");

        LinkedHashMap map=(LinkedHashMap) getTextMap(dataBean,textBean);
        Iterator it=map.entrySet().iterator();
        while(it.hasNext()){
            Entry<String, Integer> entry=(Entry) it.next();
            mailBody.append("<tr><td>"+entry.getKey()+"</th><td class='count'>"+entry.getValue()+"</td></tr>");
        } 


        BodyPart messageBodyPart1 = new MimeBodyPart();

        messageBodyPart1.setContent(mailBody.toString(), "text/html");

        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(messageBodyPart1);

        message.setContent(multipart);

        Transport.send(message);

}

代码语言:javascript
复制
public Session getAuthentication() {

    final String host = this.props.getProperty("from");
    final String password = this.props.getProperty("password");
    properties.setProperty("mail.smtp.host", this.props.getProperty("hostName"));
    Session session = Session.getInstance(properties,null);
    return session;

}

textTo:该字符串包含3个电子邮件地址textCc:该字符串包含1个通讯组列表,该列表包含8个电子邮件地址。

所有这些都是有效的电子邮件地址。我检查了SendFailedException.Seems中的getValidUnsentAddresses(),所有这些都是有效的,但没有发送出去。

EN

回答 1

Stack Overflow用户

发布于 2015-06-30 17:04:28

这就是所谓的灰色列表。当您发送太多电子邮件(或者更常见的情况是,在收件人不存在的情况下,发送了一定数量的电子邮件),目标邮件服务器不会将您列入黑名单,而是会暂时阻止从您的邮件服务器(本质上是您的邮件服务器的IP地址)进行访问。通常此块设置为1小时,但显然可以根据配置的不同而有所不同。

您可以做以下几件事:

1.联系相关域名的管理员(例如postmaster@messaging.sprintpcs.com),请求将您的IP地址列入白名单。(他们可以拒绝)。

2.检查/增加电子邮件在本地队列中的停留时间(以获得更多重试并最终送达的机会。

3.向您的服务器添加更多公有IP地址

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31133590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档