1

After syncing my local maildir inboxes with offlineimap and performing spam filtering and sorting using fdm+bogofilter, I tag the messages in the mail store using notmuch.

Up until recently, I used the following shell code to tag and re-tag messages depending on certain criteria:

notmuch new

tr -s '\t' ' ' <<'END_BATCH' | notmuch tag --batch
-inbox +sent            -- folder:/Sent/
-inbox +archive         -- folder:/Archive/
-inbox +junk            -- folder:/Junk/
+unsorted               -- folder:/INBOX.Unsorted/
-unsorted               -- not folder:/INBOX.Unsorted/
-unread -- tag:archive
+unread -- tag:unsorted
END_BATCH

This removes the inbox tag from any message in a Sent, Archive or Junk folder, while retagging the messages with the appropriate tags for those three folders. It then tags or untags messages depending on whether they are in an INBOX.Unsorted folder (where I put messages that bogofilter couldn't classify). Lastly, I ensure that archived messages are not tagged as unread and that unsorted messages are tagged as unread.

This worked well.

Since I receive mail on five different accounts, I then also wanted to add tags like account-somename, account-othername etc. to messages, depending on the folder name:

notmuch new

tr -s '\t' ' ' <<'END_BATCH' | notmuch tag --batch
-inbox +sent            -- folder:/Sent/
-inbox +archive         -- folder:/Archive/
-inbox +junk            -- folder:/Junk/
+unsorted               -- folder:/INBOX.Unsorted/
-unsorted               -- not folder:/INBOX.Unsorted/
-unread -- tag:archive
+unread -- tag:unsorted
+account-acc1           -- folder:/acc1/
+account-acc2           -- folder:/acc2/
+account-acc3           -- folder:/acc3/
+account-acc4           -- folder:/acc4/
+account-acc5           -- folder:/acc5/
END_BATCH

The tagging seems to be performed as expected, but a side-effect is that new messages are marked as old (moved from the maildir's new directory to the cur directory). This in turn means mutt won't detect the new messages in the inboxes (unless I set maildir_check_cur in the mutt configuration, which I don't think is a nice solution).

I don't know why or what I could do to stop this from happening.

My notmuch configuration:

[database]
path=/home/myself/Mail/inboxes

[user]
name=myname
[email protected]
[email protected]

[new]
tags=inbox;unread

[search]

[maildir]
syncronize_flags=true

[index]
header.List=List-Id

1 Answer 1

1

This seems to happen because notmuch is a bit too pedantic about what message files should go in what Maildir subdirectory, and because offlineimap is a bit too relaxed about the same thing.

The offlineimap utility delivers mail messages into the target Maildir's new directory, as expected, but the filenames have a :2, filename suffix, denoting "this mail message have no flags". Usually, brand new, unseen, and just delivered message files should not have this filename suffix because it's the user's MUA (mail client) that adds it.

When notmuch is configured to synchronise Maildir flags (which you most likely want it to do), it notices that the message files have the :2, filename suffix and therefore assumes that the user must have seen the messages in their MUA, but that they have not read them (there is no S after the comma in the suffix). It then moves the message files to the cur directory. The mutt mail client consequently displays them as "old" (seen but unread).

The solution would be to correct the behaviour of offlineimap, but it was already brought up as a bug and dismissed in 2015.

My solution is to take offlineimap out of the equation. Instead, I fetch all my mail using fdm. I might look into another IMAP syncing solution later (mbsync?) because having a few weeks' worth of mail on the mail servers is good for accessing it away from my main machine.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.