如何通过Commons ImapClient获取有用的邮件信息?不仅是布尔状态,还是真实信息? [英] How get useful mail info with commons ImapClient? Not just boolean status but real info?

查看:224
本文介绍了如何通过Commons ImapClient获取有用的邮件信息?不仅是布尔状态,还是真实信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的行家是

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

我的代码如下

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
    }
}

我该如何使用apache commons客户端抓取消息?所有方法都返回boolean或void,所以好像只是服务器检查库,对吗? 是否有可能以某种方式从imapclient获得有用的信息?我的意思是未读消息,消息对象(内容+标题+目录)的数量,等等.

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当然具有我需要的所有功能,但是在50K循环中使用它会非常慢(我在

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(

推荐答案

最后,通过简单地遍历文件系统(我具有maildir格式)解决了我的问题. 我猜Java Mail API在store.connect中为每个用户创建了新的dovecot身份验证,而它应该只连接一次(使用dovecot身份验证),然后为每个用户登录(使用dovecot imap登录).这就是为什么我每次迭代都等待1分钟的原因-dovecot配置中的身份验证过程处于标准空闲状态.我不确定,但看起来是这样.

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库运行很快,但它只是测试用于ping服务器的库,用于检查连接和其他imap操作.它返回有关操作的布尔结果,但不返回有用的信息(

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(

这篇关于如何通过Commons ImapClient获取有用的邮件信息?不仅是布尔状态,还是真实信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆