Avoiding the "huge INBOX of death"
Vladimir Marek
Vladimir.Marek at oracle.com
Tue Jul 19 03:36:11 PDT 2016
I can't speak for everyone, but here's what I am using.
I do have 'messages' directory which contains 'imap' and 'archive'.
messages
\-imap
\-archive
The imap directory is being synchronized via offlineimap to the server.
In the offlineimap postsync hook I call a script which does some
bookkeeping on the newly received messages and it also marks old and
already read and not flagged emails by the 'old-tread' tag.
N=notmuch
while : ; do
AGE=100d # 100 days
# Find all threads containing old messages
OLD_MESSAGES=$( $N search --output=threads not tag:archive and date:..$AGE and not tag:unread and not tag:flagged )
[ -n "$OLD_MESSAGES" ] || break
# Find threads containing newer messages
NEW_MESSAGES=$( $N search --output=threads not tag:archive and not '(' date:..$AGE or tag:unread or tag:flagged ')' )
# remove the threads containing newer messages
OLD_THREADS=$( /usr/xpg4/bin/fgrep -v -x -f <(echo "$NEW_MESSAGES") < <(echo "$OLD_MESSAGES") )
[ -n "$OLD_THREADS" ] || break
$N tag +old-thread -- $OLD_THREADS
break
done
# If old thread received newer message, unmark it too
$N tag -old-thread -- tag:old-thread and '(' not date:..$AGE or tag:unread or tag:flagged or tag:archive ')'
Once in a while I review the old-thread messages and assign them by hand
'archive' flag. The postsync hook is looking for this flag and moves all
messages to be archived into archive folder. You can list files to be
archived by
$N search --output=files 'path:imap/**' tag:archive
I won't list the commands to move files from messages/imap to
messages/archive since I have a bit more complex scenario. But it should
be straightforward.
On next run offlineimap sees that the messages disappeared from 'imap'
folder and removes them from imap server.
$ notmuch count '*'
734346
$ notmuch count 'path:imap/**'
18419
In my case I am server side filtering the emails into several folders so
that I have at least some order in emails when reading email via phone,
so 'path:imap/**' contains all the messages in whole imap tree.
$ notmuch count 'path:imap/** and tag:inbox and tag:unread'
11
I'm trying to have my virtual INBOX empty most of the time.
I'm interested what tricks others use!
Cheers
--
Vlad
More information about the notmuch
mailing list