|
@@ -67,6 +67,16 @@ public class EmailUtil {
|
|
|
public static IMAPStore getIMAPStore(MailboxInfo mailboxInfo) throws MessagingException {
|
|
|
Properties ImapProperties = new Properties();
|
|
|
ImapProperties.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
|
|
+ // 开启ssl
|
|
|
+ ImapProperties.put("mail.imap.ssl.enable", true);
|
|
|
+ // 套接字连接超时值(毫秒)。此超时由java.net.Socket实现。默认是无限超时。
|
|
|
+ ImapProperties.put("mail.imap.connectiontimeout", 1000 * 60);
|
|
|
+ // 套接字读取超时值(毫秒)。此超时由java.net.Socket实现。默认是无限超时。
|
|
|
+ ImapProperties.put("mail.imap.timeout", 1000 * 60);
|
|
|
+ // 套接字写超时值,单位为毫秒。此超时是通过使用java.util.concurrent实现的。
|
|
|
+ // ScheduledExecutorService每个连接,调度线程在超时过期时关闭套接字。
|
|
|
+ // 因此,使用此超时的开销是每个连接一个线程。默认是无限超时。
|
|
|
+ ImapProperties.put("mail.imap.writetimeout", 1000 * 60);
|
|
|
|
|
|
Session session = Session.getInstance(ImapProperties);
|
|
|
IMAPStore store = (IMAPStore) session.getStore("imap");
|