【问题标题】:Error 554 Message does not conform to standards错误 554 消息不符合标准
【发布时间】:2020-03-23 19:29:42
【问题描述】:

仅当我尝试使用 javax 库发送邮件时才收到此错误。如果我从我的邮件客户端发送它,它工作正常。

Properties properties = new Properties();
        properties.put("mail.transport.protocol", "smtp");
        properties.put("mail.smtp.host",server); // smtp.gmail.com?
        //properties.put("mail.smtp.port", "25");
        properties.put("mail.smtp.auth", "true");
        Authenticator authenticator = new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, pass);
            }
        };
        Session session = Session.getDefaultInstance(properties, authenticator);
         Message message =new MimeMessage(session);
         message.setFrom(new InternetAddress("alert@test.com"));
         message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("alert1@test.com",false));
         message.setSubject("test");
         message.setText("hi");        
         Transport.send(message);
         System.out.println("mail sernt");

我浏览了这些帖子,https://stackoverflow.com/questions/24688111/smtp-554-analysisSMTP: Error 554, message is not RFC compliantWhat does props.put("mail.smtp.host", host) in JavaMail do? 所有这些似乎都表明 IP 地址可能被阻止/与 SMTP 有关。但是,我的邮件客户端工作正常。这与 SMTP 配置有关还是我错过了什么。?

当我尝试调试时,我得到文件未找到异常:jre1.6.0\lib\javamail.providers 和 javamail.address.map。是否与这些异常有关。还有如何检查我的防火墙是否不是问题。

【问题讨论】:

  • 放另一个属性properties.put("mail.smtp.starttls.enable", "true");
  • @ricky2527 添加让我 javax 邮件异常:' javax.mail.MessagingException: Can't send command to SMTP host;嵌套异常是:javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径'
  • 你可以在这里找到这个问题的解决方案。 stackoverflow.com/questions/14771061/…).

标签: java email


【解决方案1】:

我收到了该响应(错误 554 消息不符合标准),但是当我将邮件从格式更改为此格式时它停止了:

"<alert@test.com>"

如果有帮助,请尝试。

【讨论】:

  • 嗨@klarki,感谢您的回复。我试过这个。我再次收到消息说消息不符合 554 标准。
【解决方案2】:

你能解决问题吗?我试过它没有给出任何异常,我几乎没有从你的代码中改变一些东西。如果对你有帮助,请看一下。

    final String username = "myUserName";   //enter your user name
    final String password = "myPassword";  //enter password

    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", "");       //enter host name
    props.put("mail.smtp.port", "");       //enter port no here

    Session session = Session.getInstance(props,
            new javax.mail.Authenticator(myUserName) {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(userName, password);
                }
            });

    try {

        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(userName));
        message.setRecipients(Message.RecipientType.TO,
                InternetAddress.parse("reciverMailAddress"));
        message.setSubject("Test");
        message.setText("This is the body of the email");
        Transport.send(message);

        System.out.println("Done");


    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
}

【讨论】:

  • 我尝试了所有这些,并尝试从您提到的链接运行 InstallCert,从 installCert 我无法连接到主机,但我能够 ping。现在,我很困惑是网络(防火墙)问题还是代码问题。
  • 我的代码运行良好,所以一定是防火墙问题或其他问题。
  • 我认为这不是防火墙问题,就像您所说的“其他问题”。很可能需要满足某些标准的 smtp 服务器配置。
【解决方案3】:

问题在于日期。消息“消息不符合 554 标准是因为日期。添加

message.setSentDate(new Date());

解决了这个问题。

这个SMTP: Error 554, message is not RFC compliant 帮助了。

【讨论】:

    猜你喜欢
    • 2010-09-18
    • 1970-01-01
    • 1970-01-01
    • 2010-11-13
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多