【问题标题】:Maildrop: Filter mail by Date: headerMaildrop:按日期过滤邮件:标题
【发布时间】:2011-01-31 05:09:37
【问题描述】:

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

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

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

【问题讨论】:

    标签: email procmail


    【解决方案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 format 中)并生成一个格式化的日期以用作邮件文件名。

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

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

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

    【讨论】:

      猜你喜欢
      • 2020-08-28
      • 2013-11-25
      • 1970-01-01
      • 1970-01-01
      • 2018-09-08
      • 2019-03-01
      • 2016-01-10
      • 2018-11-07
      • 1970-01-01
      相关资源
      最近更新 更多