问题描述
现在我有一个程序定时收取1000账号的邮件,但是发现程序跑一段时间后就报错说拒绝连接,重启服务后又可以收取邮件,也是跑一段时间后就拒绝连接。大神救人啦Propertiesprop=System.getProperties();Storestore=null;if(Boolean.valueOf(mailsCheckEvent.getEncrypt())){prop.setProperty("mail.imap.socketFactory.class","javax.net.ssl.SSLSocketFactory");prop.setProperty("mail.imap.socketFactory.fallback","false");prop.setProperty("mail.imap.socketFactory.port",mailsCheckEvent.getPort()+"");}prop.setProperty("mail.imap.port",mailsCheckEvent.getPort()+"");//获取address.properties中的例外信息prop.setProperty("mail.imap.host",AddressConfig.getValue(mailsCheckEvent.getMailAddress(),mailsCheckEvent.getMailAddress()));prop.put("mail.imap.auth","true");prop.put("mail.store.protocol",mailsCheckEvent.getReceiveProtocol());/**Sessionsession=Session.getInstance(prop,new*MailAuthenticator(mailsCheckEvent.getMailAccout(),*getPassword(mailsCheckEvent.getPassword())));*/Sessionsession=Session.getDefaultInstance(prop,newMailAuthenticator(mailsCheckEvent.getMailAccout(),getPassword(mailsCheckEvent.getPassword())));store=session.getStore();store.connect();pop3Folder=(POP3Folder)store.getFolder("INBOX");pop3Folder.open(Folder.READ_ONLY);Message[]message=pop3Folder.getMessages();FetchProfileprofile=newFetchProfile();profile.add(UIDFolder.FetchProfileItem.UID);pop3Folder.fetch(message,profile);然后就是循环message了。
解决方案
解决方案二:
其他错误信息由没有。