Maildrop:按日期过滤邮件:标题

发布于 2024-10-15 04:55:02 字数 605 浏览 2 评论 0原文

我正在使用 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”。 任何帮助、想法、链接、材料将不胜感激。

I'm using getmail + maildrop + mutt + msmtp chain with messages stored in Maildir. Very big inbox bothers me, so i wanted to organize mail by date like that:

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

I've googled much and read about mailfilter language, but still it is hard for me to write such filter. Maildrop's mailing list archives has almost nothing on this (as far as i scanned through it). There is some semi-solution on https://unix.stackexchange.com/questions/3092/organize-email-by-date-using-procmail-or-maildrop, but i don't like it, because i want to use "Date:" header and i want to sort by month like "YEAR.MONTH" in digits.
Any help, thoughts, links, materials will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-10-22 04:55:02

我主要使用 man 页面,想出了以下在 Ubuntu 10.04 上使用的解决方案。创建一个名为 mailfilter-archivemailfilter 文件,其中包含以下内容:

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等邮件文件。

Using mostly man pages, I came up with the following solution for use on Ubuntu 10.04. Create a mailfilter file called, for example, mailfilter-archive with the following content:

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

This uses the date command, taking the date header content as input (assuming it is in RFC-2822 format) and producing a formatted date to use as the mail file name.

Then execute the following on existing mail files to archive your messages:

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

If the mail-archive contents look good, you could remove the mail1, mail2, mail3, mail4, etc. mail files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文