Using procmail to set tags

Tomi Ollila tomi.ollila at iki.fi
Tue May 15 06:43:31 PDT 2012


On Tue, May 15 2012, Austin Clements <amdragon at MIT.EDU> wrote:

>
> Alternatively, you can have procmail record the message ID and desired
> tags of the message in a file and then apply those recorded tags in
> your post-new hook.  This would achieve the tagging you want more
> directly, without mixing in folders and multiple delivery.  The
> difficulty would be getting a message ID you could later use in an id:
> query.  Simply grabbing the value of the message-id header would work
> most of the time, but there's a fair bit of logic for dealing with
> strangely formed or completely malformed message-id headers
> (see _parse_message_id).

If procmail is delivering one mail at a time (without parallerism) and
notmuch new is executed after each email delivered one could try

  * put desired tags into environment (export NEW_TAGS='+foo +bar')
  * execute notmuch new
  * use the environment variables in post-new hook 
      (notmuch tags $NEW_TAGS -new tag:new)

The risk with this approach (when not recording message-id) is that there
ie not just one new mail (with 'new' tag) delivered...

Then I sidedtacked to... wouldn't something like
         notmuch new +<tags> -<tags> [path/to/filename]
be so cool... ;) (yes, so non-trivial...)

>
> As far as I know, nobody has tried my second suggestion.  Most people
> just switch to using notmuch queries (either to tag or simply to
> search).

Tomi


More information about the notmuch mailing list