仅当我尝试使用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("[email protected]"));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("[email protected]",false));
message.setSubject("test");
message.setText("hi");
Transport.send(message);
System.out.println("mail sernt");
我通过这些帖子,去https://stackoverflow.com/questions/24688111/smtp-554-analysis,SMTP:错误554,消息不符合RFC,这是什么props.put(“mail.smtp.host”,主持人)在JavaMail中做什么?所有这些似乎都表明IP地址可能已被阻止/与SMTP相关。但是,我的邮件客户端工作正常。这与SMTP配置有关还是我错过了什么?
当我尝试调试时,找不到文件jre1.6.0 \ lib \ javamail.providers和javamail.address.map的异常。与这些例外有关。另外,如何检查我的防火墙是否不是问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句