gpt4 book ai didi

java - com.sun.mail.smtp.SMTPAddressFailedException : 554 5. 7.1 :客户端主机被拒绝:访问被拒绝

转载 作者:行者123 更新时间:2023-11-29 07:48:17 27 4
gpt4 key购买 nike

我正在尝试使用 JavaMail 发送邮件。

properties.put("mail.smtp.host", "smtp.estudiantes.ve");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.port",25);
properties.put("mail.smtp.mail.sender","miemail@estudiantes.ve");
properties.put("mail.smtp.user", "miemail@estudiantes.ve");
properties.put("mail.smtp.auth", "true");

session = Session.getDefaultInstance(properties);
session.setDebug(true);

System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("javax.net.ssl.trustStore", "C:/Program Files/Java/jdk1.7.0_51/jre/lib/security/cacerts");

try{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress((String)properties.get("mail.smtp.mail.sender")));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("amigo@estudiantes.ve"));
message.setSubject("Prueba");
message.setText("Texto");

Transport t = session.getTransport("smtp");
t.connect((String)properties.get("mail.smtp.user"), "contrasenna");
t.sendMessage(message, message.getAllRecipients());
t.close();
}catch (MessagingException me){
//Aqui se deberia o mostrar un mensaje de error o en lugar
//de no hacer nada con la excepcion, lanzarla para que el modulo
//superior la capture y avise al usuario con un popup, por ejemplo.
return;
}

但是,它会抛出以下异常:

 javax.mail.SendFailedException: Invalid Addresses (com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 <cdae-jee-302-01.uci.cu[10.56.14.157]>: Client host rejected: Access denied)
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1446)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:736)
at uci.dalasqq.vista.AlarmasBean.sendEmail(AlarmasBean.java:116)
at uci.dalasqq.vista.DashboardBean.updatepkicolors(DashboardBean.java:337)
at uci.dalasqq.vista.DashboardBean.mainConfigPKI(DashboardBean.java:661)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)

Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 554 5.7.1 <cdae-jee-302-01.uci.cu[10.56.14.157]>: Client host rejected: Access denied
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1344)
... 36 more

这是怎么引起的,我该如何解决?

最佳答案

据我所知,您的代码工作正常,但您使用的邮件服务器拒绝您的邮件并出现错误:

554 5.7.1 <cdae-jee-302-01.uci.cu[10.56.14.157]>: Client host rejected: Access denied

也许您需要登录到服务器,或者从不同的主机连接?

关于java - com.sun.mail.smtp.SMTPAddressFailedException : 554 5. 7.1 <cdae-jee-302-01.uci.cu[10.56.14.157]>:客户端主机被拒绝:访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23485284/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com