0

为了通过 java 邮件 API 连接 hotmail 帐户,我正在设置这些属性

pop3Props.setProperty("mail.pop3.ssl.enable", "true");
pop3Props.setProperty("mail.pop3s.socketFactory.class", SSL_FACTORY); 
pop3Props.setProperty("mail.pop3s.socketFactory.fallback", "false");    
pop3Props.setProperty("mail.pop3s.port", "995");   
pop3Props.setProperty("mail.pop3s.socketFactory.port", "995");

Properties pop3Props = new Properties();
pop3Props.setProperty("mail.pop3s.port",  "995");

Session session = Session.getInstance(pop3Props, null);
Store store = session.getStore("pop3s");
store.connect(host, 995, username, password);

我能够登录到我的 hotmail 帐户并执行其他操作(发送/接收),但
一段时间后(我认为)会话超时发生,即无法连接到 hotmail 服务器。稍后某个时间再次运行正常(我能够连接到 hotmail
服务器)。我检查了我的代码,每当我打开一个新连接时,我也会关闭它。请帮忙 。

4

1 回答 1

0

Are you leaving the connection open for long periods of time without doing anything?

Are you opening and closing the connection frequently over short periods of time?

Servers have lots of ways of preventing you from "abusing" their resources. You may be running into one of them.

Or, maybe you have an unreliable network connection?

See the JavaMail FAQ for debugging tips; the debug output might provide more clues as to why it's failing.

Also see the list of common mistakes; you can simplify your code.

于 2013-08-23T18:51:32.523 回答