1

我正在将 getmail + maildrop + mutt + msmtp 链与存储在 Maildir 中的消息一起使用。非常大的收件箱困扰着我,所以我想像这样按日期组织邮件:

Maildir
|-2010.11->all messages with "Date: *, * Nov 2010 *"
|-2010.12->same as above...
|-2011.01
`-2011.02

我已经搜索了很多并阅读了有关邮件过滤器语言的信息,但我仍然很难编写这样的过滤器。Maildrop 的邮件列表档案几乎没有这方面的内容(据我浏览它)。https://unix.stackexchange.com/questions/3092/organize-email-by-date-using-procmail-or-maildrop上有一些半解决方案,但我不喜欢它,因为我想使用“日期:”标题,我想按月份排序,如数字中的“YEAR.MONTH”。任何帮助、想法、链接、材料将不胜感激。

4

1 回答 1

1

主要使用man页面,我想出了以下在 Ubuntu 10.04 上使用的解决方案。mailfilter例如,创建一个名为的文件,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 格式)并生成一个格式化的日期以用作邮件文件名。

然后对现有邮件文件执行以下操作以存档您的邮件:

cat mail1 mail2 mail3 mail4 | reformail -s maildrop mailfilter-archive

如果mail-archive内容看起来不错,您可以删除mail1mail2mail3mail4等邮件文件。

于 2011-12-20T19:22:43.430 回答