1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Approaches to initial tagging of messages
4 This page collects scripts and strategies for organizing mail using
5 notmuch and doing automated initial tagging.
7 The `[new]` config section allows you to control which tags new messages
8 receive. By default, `notmuch config` will use the tags *inbox* and *unread*.
10 If `maildir.synchronize_flags` is true (which is the default), Maildir flags
11 have precedence over the initial tags. Thus an already read mail gets its
12 initial *unread* tag correctly removed.
14 ## The *new* tag approach
16 Here's another very general and ad-hoc approach to initial message tagging,
17 which sets all new messages to get the *new* tag:
22 After running `notmuch new`, all new messages will be marked *new*.
23 You can then do various tag post-processing by just acting on messages
24 with that tag. For instance, a post-processing script might do the
27 # immediately archive all messages from "me"
28 notmuch tag -new -- tag:new and from:me@example.com
30 # delete all messages from a spammer:
31 notmuch tag +deleted -- tag:new and from:spam@spam.com
33 # tag all message from notmuch mailing list
34 notmuch tag +notmuch -- tag:new and to:notmuch@notmuchmail.org
36 # finally, retag all "new" messages "inbox" and "unread"
37 notmuch tag +inbox +unread -new -- tag:new
39 Note that the command above will mark a new but already-read mail as unread.
41 Since the post-processing is only acting on a few messages, it is
42 generally extremely fast.
44 You can use the `post-new` hook, which is automatically run after `notmuch new`,
45 to do post-processing. See `man notmuch-hooks` for details on hooks.
50 * [Carl Worth's approach to tagging](https://notmuchmail.org/pipermail/notmuch/2010/001691.html). It
51 is email id:87r5o8stbj.fsf@yoom.home.cworth.org in the notmuch
52 mailing list archives.
55 * [One user's setup](https://notmuchmail.org/pipermail/notmuch/2010/001690.html)
56 (id:87hbp5j9dv.fsf@hackervisions.org), which includes using the
57 inbox tag as a "new mail" flag.
59 * [Another user's setup](https://notmuchmail.org/pipermail/notmuch/2011/003976.html)
60 (id:"87tyfu3k5a.fsf@gmail.com"), which uses a dedicated tag for
61 marking new mail, which is then sorted with a python script using
62 Bogofilter for spam detection. This is generally a great deal
63 faster than a shell-scripted approach. This approach introduces a
64 workflow built around a "watch" tag. Here, the user is only
65 presented with threads as they are started. At this point the user
66 can choose to watch the thread, in which case future messages will
67 be tagged with "inbox", or ignore it. This provides an excellent
68 means for dealing with a large flux of messages with a low
71 * [afew](https://github.com/teythoon/afew) is an initial tagging
72 solution that should work out of the box for most basic tagging
73 needs (mailinglist handling, killed thread handling, autoarchiving
74 of sent mails) and has some fancy features (e.g. mail classification
75 using bayesian filters).
77 * [p6-notmuch-filter](https://github.com/goneri/p6-notmuch-filter) a initial
78 tagging script that read its configuration from a JSON file. The script is
79 written in Perl6 and depends on the Email::Notmuch binding.
81 ## Notmuch MDA -- `notmuch-insert`
83 The [[notmuch insert command|manpages/notmuch-insert-1]] is a tool for
84 delivering emails to maildir, indexing them to the Notmuch database, and tagging