Email. We get a lot of it. We filter out the SPAM. Then if we're well-organized we file it away into folders as it arrives. (To be fair some people use priority settings such that all mail stays in their INBOX until they're "done" with it. I've never had the patience for that kind of behaviour.)
One problem which I often encounter is wanting to have email be delivered, archived, and stored, but I don't want to read it. Yet when I see a folder in my mail client which has unread mail in it I cannot unsee.
In my case I deliver mail to folders as it arrives via either Exim's filter language, or procmail. Procmail blows goats on the whole, but it is common and available everywhere - I just don't trust my own DSL enough to rely upon it (which is a dangerous sign).
So, how do you deliver a new mail to a Maildir folder, and mark it read at the same time? Well you can be naïve and do what I did which is to invoke formail to add "Status: ro" to the header. Unfortunately that's insufficient to mark a mail as read when viewed in mutt.
When an email is stored in a Maildir folder its status is encoded in part of its filename - which is why you'll have files like:
The latter file has been Seen. So to mark a message as not-new you need to do two things:
- Save it to ./cur/ not ./new/.
- Append the appropriate flags to the filename (generally :2,S).
I've seen some horrific shell + procmail code to do the job, but the simpler version is:
:0 *^(To:|From:).*root@ *^X-added-header:.*debian-administration.org | ~/bin/read-to-maildir .machines.debian-administration.org/
Similarly you can use Exim's filter language to do the same job:
# Exim filter if $h_to: contains "hostmaster@" then pipe "/home/skx/bin/read-to-maildir /home/steve/Maildir/.hostmaster/" finish
Cute. Obvious too? Maybe not to me.
ObSubject: Why did you murder someone, Raymond? - In Bruges