IMAP文件夹差异?

时间:2009-10-12 13:41:25

标签: linux command-line imap spam

我想“区分”两个IMAP文件夹(在两个不同的服务器上)来比较垃圾邮件过滤器,我想要一个命令行工具(linux)来获取标题(不是整个目录,例如使用'isync'或类似的东西),像这样:

$ imapget --subjects -p = password user @ server

或者这个:

$ imapget --format“$ DATE - $ FROM - $ SUBJ”-p = password user @ server

('imapget'cmd是虚构的)

你会建议什么?

谢谢

2 个答案:

答案 0 :(得分:1)

我会使用诸如OfflineIMAP,imapsync,imapcopy,isync或mailsync之类的东西将两个IMAP文件夹镜像到本地Maildir文件夹。

然后我会使用像mailutils这样的东西来输出两者中的消息列表并将它们区分开来。

答案 1 :(得分:0)

简单方法可能是获取perl和Mail :: IMAPClient并使用类似的东西:

     use Mail::IMAPClient;
     my $imap = Mail::IMAPClient->new(
         Server => $imaphost, User => $login, Password => $pass, Uid => 1
     );

     $imap->select("demo_folder");

     my $msgs = $imap->search("ALL");
     for my $h (

      # get specified headers from every message in folder "demo_folder" the

       values %{ $imap->parse_headers( $msgs , "Date", "From", "Subject") } )
     {
         # $h is the value of each element in the hash ref returned
         # from parse_headers, and $h is also a reference to a hash.
         # We'll only print the first occurrence of each field because
         # we don't expect more than one particular header line per
         # message.
         print map { "$_:\t$h->{$_}[0]\n"} keys %$h;
     }