繁体   English   中英

javax.mail.messagingexception连接超时连接

[英]javax.mail.messagingexception connection timed out connect

下面的代码是Web应用程序的一部分。 这负责与Outlook邮件服务器连接。

    ls_user_pass = ldch_sys_users.getItemValue(1, "user_password").toString();      

    Store store = null;     
    String lstr_host = "",lstr_result= "no";
        HttpSession lssessionUserAuth = (HttpSession) ahm_args.get("session");  
        try {               

                Properties properties = new Properties();
                properties.setProperty("mail.store.protocol", "imaps");
                Session session = Session.getInstance(properties, null);                                
                lstr_host = "outlook.office365.com";                    
                store = session.getStore("imaps");
                store.connect(lstr_host, "rajesh___@outlook.com", ls_user_pass);
                if (store.isConnected()) {
                lstr_result = "yes";
                }               
        }catch(AuthenticationFailedException e){

        }
        return lstr_result;
}

当我在服务器上部署war时,出现此错误javax.mail.messagingexception连接超时,连接超时。 我已经打开了几个端口587,143,25,并且服务器防火墙已关闭。

但是当我在本地系统上通过eclipse进行工作时,它工作正常,没有任何问题。

看来还是防火墙/网络问题。 如果您是从本地发送邮件,则可以使用WireShark检查流/端口等,之后,可以再次检查服务器的防火墙配置。

您也可以尝试手动设置端口:properties.put(“ mail.smtp.port”,“ 587”); //“ 587”应该是字符串,否则将使用端口25

如需进一步操作,请写下检查结果。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM