How get useful mail info with commons ImapClient? Not just boolean status but real info?

淺唱寂寞╮ 提交于 2020-01-05 06:25:30

问题


My maven is

<dependency>
    <groupId>commons-net</groupId>
    <artifactId>commons-net</artifactId>
    <version>3.3</version>
</dependency>

My code is the following

IMAPClient client = new IMAPClient();
client.connect("localhost");
for(50K users){
    client.login(login + emailSuffix, password);
    for (int i = 0; i < folders.length; i++) {
        System.out.println(client.select("INOX"); //prints true, it's ok
    }
}

How may I grab messages with apache commons client? All methods return boolean or void, so it's looks like just server checking library am I right? Is it possible to somehow get useful info from imapclient? I mean number of unread messages, Message objects (content+headers+sibject) by some term and so on.

P.S. Java Mail api of course has all functions I need but it very slow for using it in 50K loop (My efforts on Java Mail API described on other SO question. Commons is much more faster in connection but couldn't give useful info(


回答1:


Finally solved my problem by simple iterating over file system (I have maildir format). I guess Java Mail API makes new dovecot auth for each user in store.connect while it should just connect once (consume dovecot auth) and after that login for each user (consume dovecot imap-login). That's why I waited 1 minute for each iteration - it's std idle for auth process in dovecot config. I'm not sure but looks so.

Apache lib works fast but it's just testing library for pinging server, checking connection and other imap operations. It returns boolean result about operations but not useful information(



来源:https://stackoverflow.com/questions/38121397/how-get-useful-mail-info-with-commons-imapclient-not-just-boolean-status-but-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!