简体   繁体   English

无法连接到SMTP主机:smtp8.net4india.com,端口:25;

[英]Could not connect to SMTP host: smtp8.net4india.com, port: 25;

While sent email showing error: 在发送显示错误的电子邮件时:

javax.mail.MessagingException: Could not connect to SMTP host: smtp8.net4india.com, port: 25;
  nested exception is:
    java.net.ConnectException: Connection timed out: connect

My email settings is: 我的电子邮件设置是:

        String mailProcessed = "";
        Properties props = new Properties();
        props.put("mail.smtp.host", "smtp8.net4india.com");
        props.put("mail.smtp.socketFactory.port", "25");
        props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "25");
        props.put("mail.smtp.starttls.enable", "true");

        Session session = Session.getDefaultInstance(props,
                new javax.mail.Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(frmMail, frmPass);
                    }
                });

remove props.put("mail.smtp.starttls.enable", "true"); 删除props.put("mail.smtp.starttls.enable", "true");

and add props.put("mail.smtp.ssl.enable", "true"); 并添加props.put("mail.smtp.ssl.enable", "true");

You are using SSL, not TLS. 您正在使用SSL,而不是TLS。

Also make sure the mail server supports SSL. 还要确保邮件服务器支持SSL。

Also make sure that the mail server is using TCP protocol SMTP , they might be using IMAP or POP3 . 还要确保邮件服务器正在使用TCP协议SMTP ,它们可能正在使用IMAPPOP3 In that case you need to change the properties you reference by the protocol they use, ie: props.put("mail.pop3.socketFactory.port", "25"); 在这种情况下,您需要通过使用的协议来更改引用的属性,即: props.put("mail.pop3.socketFactory.port", "25"); props.put("mail.pop3.socketFactory.class","javax.net.ssl.SSLSocketFactory");

You are using getDefaultInstance for the session, but if a session was already established it will return the existing session and your properties will be lost. 您正在为会话使用getDefaultInstance ,但是如果已经建立了会话,它将返回现有会话,并且您的属性将丢失。

Check the common mistakes page, it has it all: https://javaee.github.io/javamail/FAQ#commonmistakes 检查常见错误页面,它具有全部内容: https : //javaee.github.io/javamail/FAQ#commonmistakes

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法连接到SMTP主机:…,端口:25? - Could not connect to SMTP host: …, port: 25? grails:无法连接到SMTP主机:*********,端口:25 - grails : Could not connect to SMTP host: *********, port: 25 无法连接到SMTP主机:smtp.gmail.com,端口:465 - could not connect to smtp host:smtp.gmail.com, port:465 javax.mail.MessagingException:无法连接到 SMTP 主机:email-smtp.us-east-1.amazonaws.com,端口:25; - javax.mail.MessagingException: Could not connect to SMTP host: email-smtp.us-east-1.amazonaws.com, port: 25; 回复邮件时无法连接到SMTP主机:localhost,端口:25- - Could not connect to SMTP host: localhost, port: 25 - while REPLYing to mail SMTP主机:smtp.outlook.com中的连接错误,端口:25 - Connection Error in SMTP host :smtp.outlook.com, port: 25 javax.mail.MessagingException:无法连接到SMTP主机:smtp.gmail.com,端口:587; java.net.NoRouteToHostException:主机没有路由 - javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587; java.net.NoRouteToHostException: No route to host 无法连接到SMTP主机:smtp.gmail.com,port:587; 嵌套异常是:java.net.ConnectException:连接超时:连接 - Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.ConnectException: Connection timed out: connect 使用Java的电子邮件通知我可能会遇到错误,因为无法连接到SMTP主机:RELAY.MY.COM,端口:25,响应:421 - Email notification using java i can face error as Could not connect to SMTP host: RELAY.MY.COM, port: 25, response: 421 javax.mail.MessagingException:无法连接到SMTP主机:<主机名>端口:25响应:554 - javax.mail.MessagingException: Could not connect to SMTP host : <host name> port : 25 response: 554
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM