我使用getmail + maildrop + mutt + msmtp链与Maildir中存储的消息。非常大的收件箱困扰我,所以我想按日期组织邮件:
Maildir
|-2010.11->all messages with "Date: *, * Nov 2010 *"
|-2010.12->same as above...
|-2011.01
`-2011.02
我用google搜索了很多关于mailfilter语言的内容,但是我仍然很难编写这样的过滤器。 Maildrop的邮件列表档案几乎没有任何内容(就我通过它扫描而言)。在https://unix.stackexchange.com/questions/3092/organize-email-by-date-using-procmail-or-maildrop上有一些半解决方案,但我不喜欢它,因为我想使用"日期:"标题,我希望按月排序,例如" YEAR.MONTH"用数字。 任何帮助,想法,链接,材料将不胜感激。
答案 0 :(得分:1)
主要使用man
个页面,我提出了以下解决方案,以便在Ubuntu 10.04上使用。创建一个名为mailfilter
的{{1}}文件,例如mailfilter-archive
,其中包含以下内容:
DEFAULT="$HOME/mail-archive"
MAILDIR="$DEFAULT"
# Uncomment the following to get logging output
#logfile $HOME/tmp/maildrop-archive.log
# Create maildir folder if it does not exist
`[ -d $DEFAULT ] || maildirmake $DEFAULT`
if (/^date:\s+(.+)$/)
{
datefile=`date -d "$MATCH1" +%Y-%m`
to $DEFAULT/$datefile
}
# In case the message is missing a date header, send it to a default mail file
to $DEFAULT/inbox
这使用date
命令,将date
标题内容作为输入(假设它在RFC-2822 format中)并生成用作邮件文件名的格式化日期。
然后在现有邮件文件上执行以下操作以存档您的邮件:
cat mail1 mail2 mail3 mail4 | reformail -s maildrop mailfilter-archive
如果mail-archive
内容看起来不错,您可以删除mail1
,mail2
,mail3
,mail4
等邮件文件。