我想“比较”两个IMAP文件夹(在两个不同的服务器上)来比较垃圾邮件过滤器,我想有一个命令行工具(linux)来只获取标题(而不是整个目录,例如使用'isync‘或类似的),类似于:
$ imapget --主题-p=password用户@服务器
或者这样:
$ imapget --格式"$DATE - $FROM - $SUBJ“-p=password用户@服务器
('imapget‘cmd是虚构的)
你有什么建议?
谢谢
发布于 2009-11-21 17:19:57
我会使用OfflineIMAP、imapsync、imapcopy、isync或mailsync等命令将这两个IMAP文件夹镜像到本地的Maildir文件夹。
然后,我会使用类似mailutils的东西来输出两者中的消息列表,并对它们进行比较。
发布于 2009-11-13 03:47:32
最简单的方法可能是获取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;
}https://stackoverflow.com/questions/1554653
复制相似问题