Пример #1
0
  private static Properties getImapMailProperties(Account account) {
    Properties props = new Properties();

    if (account.getReceiveProtocolType().contains("gmail")) {
      props.put("mail.imap.host", "imap.gmail.com");
      props.put("mail.imap.port", "143");
      props.put("mail.imap.auth", "true");
      props.put("mail.store.protocol", "imap");
      props.put("mail.imap.starttls.enable", "true");
      props.put("mail.imap.socketFactory.port", "993");
      props.put("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
      props.put("mail.iamp.socketFactory.fallback", "false");
    } else {

      props.setProperty("mail.imap.port", account.getReceivePort());
      props.setProperty("mail.imap.connectiontimeout", "30000");
      if ("ssl".equals(account.getReceiveTs())) {
        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
        props.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        props.setProperty("mail.imap.socketFactory.fallback", "false");
        props.setProperty("mail.imap.socketFactory.port", account.getReceivePort());
      } else if ("tls".equals(account.getReceiveTs())) {
        props.setProperty("mail.imap.starttls.enable", "true");
        java.security.Security.setProperty(
            "ssl.SocketFactory.provider", "com.archermind.txtbl.mail.DummySSLSocketFactory");
      }
    }

    return props;
  }
Пример #2
0
 private static Properties getPop3MailProperties(Account account) {
   Properties props = new Properties();
   props.setProperty("mail.pop3.port", account.getReceivePort());
   props.setProperty("mail.pop3.connectiontimeout", "30000");
   if ("ssl".equals(account.getReceiveTs())) {
     Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
     props.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
     props.setProperty("mail.pop3.socketFactory.fallback", "false");
     props.setProperty("mail.pop3.socketFactory.port", account.getReceivePort());
   } else if ("tls".equals(account.getReceiveTs())) {
     props.setProperty("mail.pop3.starttls.enable", "true");
     java.security.Security.setProperty(
         "ssl.SocketFactory.provider", "com.archermind.txtbl.mail.DummySSLSocketFactory");
   }
   return props;
 }