0

下面的代码是 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;
}

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

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

4

1 回答 1

1

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

也可以尝试手动设置端口:properties.put("mail.smtp.port", "587"); // "587" 应该是一个字符串,如果不是,将使用端口 25

为了进一步了解,请写下检查结果。

于 2015-11-26T13:27:47.457 回答