set status of mails in maildirs?

Hello procmailers! I'm in the situation that i want to set some of the mails i save into an maildir storage as 'read' for mails from a specific sender. While the recipes are no problem I have not the slightest idea how i could manage to set the 'read' status? Any ideas/pointers? Sebastian

In message <20070730172912.635b9e9c@roadrunner.darksystem.net>, Sebastian Krohn wrote:
I'm in the situation that i want to set some of the mails i save into an maildir storage as 'read' for mails from a specific sender.
While the recipes are no problem I have not the slightest idea how i could manage to set the 'read' status? Any ideas/pointers?
I use the following to set the "flagged" flag: :0 * my-regexp-here { TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,F' } :0 my-maildir-mail-box/ It works like a charm. To mark the mail as READ rather than "flagged" the filename extension should be R rather than F, i.e. { TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,R' } but I haven't tested this. Cheers, Nick. --

In message <20070730175130.GA1193@oberon.njm.f2s.com>, N.J. Mann wrote:
In message <20070730172912.635b9e9c@roadrunner.darksystem.net>, Sebastian Krohn wrote:
I'm in the situation that i want to set some of the mails i save into an maildir storage as 'read' for mails from a specific sender.
While the recipes are no problem I have not the slightest idea how i could manage to set the 'read' status? Any ideas/pointers?
I use the following to set the "flagged" flag:
:0 * my-regexp-here { TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,F' }
:0 my-maildir-mail-box/
On seconds thoughts, as an example that is buggy. A better example is: :0 * regexp { :0 { TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,F' } :0 my-maildir-mail-box/ } Cheers, Nick. --

In message <70EBAF0C-1916-428E-B269-DF8C19668E4C@kreme.com>, LuKreme wrote:
On 30-Jul-2007, at 11:55, N.J. Mann wrote:
{ TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,F' }
What?
I am sure if you re-word your question I will be able to answer it. However, at present I am uncertain whether you have a question or are just being plain rude. :-( Cheers, Nick. --

On 31-Jul-2007, at 11:16, N.J. Mann wrote:
In message <70EBAF0C-1916-428E-B269-DF8C19668E4C@kreme.com>, LuKreme wrote:
On 30-Jul-2007, at 11:55, N.J. Mann wrote:
{ TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,F' }
What?
I am sure if you re-word your question I will be able to answer it. However, at present I am uncertain whether you have a question or are just being plain rude. :-(
Sorry, I just have no idea what that is supposed to do. I don't even know where to begin. OK, first off, wouldn't this TRAP need to be enclosed in backticks instead of single quotes? Second off, what's it do? -- Spontaneity has its time and place.

LuKreme ("Kreemy") wrote on 1 August 2007:
On 30-Jul-2007, at 11:55, N.J. Mann wrote:
{ TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,F' }
Sorry, I just have no idea what that is supposed to do. I don't even know where to begin.
Well, gee, Kreemy. We discussed it a couple or three years ago when you were on the list. LASTFOLDER knows where in the maildir hierarchy the file was saved and what its name is. Maildir uses that :2,F thing on the end to mark messages read. Voila.
OK, first off, wouldn't this TRAP need to be enclosed in backticks instead of single quotes? Second off, what's it do?
No. See "man procmailex" for at least three examples of TRAP. Here's one of them: If you are using temporary files in a procmailrc file, and want to make sure that they are removed just before procmail exits, you could use something along the lines of: TEMPORARY=$HOME/tmp/pmail.$$ TRAP="/bin/rm -f $TEMPORARY" See "man procmailrc" for how TRAP works. Basically, when procmail is exiting, it runs whatever TRAP was set to, in the shell. (Set SHELL = /bin/sh, is my advice.) If we move the message that procmail just wrote to the maildir folder and left in a state such that the MUA will see the message as "New," then renaming that file as N.J. Mann showed would let most MUAs show the mail as "Read" instead. Oh, and ignore that mess that Michelle posted with all sorts of unnecessary pipes to sed, formail, etc. I can't even bring myself to answer that directly, as it raises my blood pressure too much. :-) -- dman

In message <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAfIuZ1uAZ0BGnLERFU1QAAMKAAAAQAAAAJZKjBXtRWk+4rgaomyaVxwEAAAAA@nomotek.com>, Dallman Ross wrote:
LuKreme ("Kreemy") wrote on 1 August 2007:
On 30-Jul-2007, at 11:55, N.J. Mann wrote:
{ TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,F' }
Sorry, I just have no idea what that is supposed to do. I don't even know where to begin.
Well, gee, Kreemy. We discussed it a couple or three years ago when you were on the list.
It was in November 2006. :-) See: http://mailman.rwth-aachen.de/pipermail/procmail/2006-November/025064.html I knew what I wanted to do, but wasn't sure of the best way to do it. David W. Tamkin was kind enough to suggest the TRAP method. Thanks for answering "Kreemy". I was just about to until I saw your reply. You explained TRAP far better than I could have done!
LASTFOLDER knows where in the maildir hierarchy the file was saved and what its name is. Maildir uses that :2,F thing on the end to mark messages read. Voila.
Actually, the :2,F "flags" the mail, it doesn't mark it as read or "seen" which is the maildir mailbox format term. To mark a message as seen you need to add ":2,S" - as Michelle Konzack correctly pointed out. (Next time I will not rush when posting a reply to the list. I _will_ double and triple check my facts!) http://cr.yp.to/proto/maildir.html has an explanation of maildir mailbox format.
Oh, and ignore that mess that Michelle posted with all sorts of
Actually, I think Michelle may be correct, but I haven't tested the recipes posted by Michelle. I suspect if you just add the :2,S suffix without moving the message from the "new" directory to the "cur", the MUA will treat the message an old unread message rather than a read message, which is what the original poster wanted. Cheers, Nick. --

N.J. Mann wrote Thursday, August 02, 2007 6:52 PM:
To mark a message as seen you need to add ":2,S" - as Michelle Konzack correctly pointed out. (Next time I will not rush when posting a reply to the list. I _will_ double and triple check my facts!)
Okay. precision is good, but I wasn't sweating the details in my general explanation. But yeah, thanks.
http://cr.yp.to/proto/maildir.html has an explanation of maildir mailbox format.
Good to keep handy.
Dallman Ross wrote:
Oh, and ignore that mess that Michelle posted with all sorts of
Actually, I think Michelle may be correct, but I haven't tested the recipes posted by Michelle.
I wasn't objecting to the underlying concept, just to the Rube-Golbergesque set of unnecessary pipes and shell calls to perform that concept. Most of it can be done in procmail without much trouble, I think. Dallman

In message <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAfIuZ1uAZ0BGnLERFU1QAAMKAAAAQAAAALCQjuT5jn0+vAWwuBRys/gEAAAAA@nomotek.com>, Dallman Ross wrote:
N.J. Mann wrote Thursday, August 02, 2007 6:52 PM: [...]
Actually, I think Michelle may be correct, but I haven't tested the recipes posted by Michelle.
I wasn't objecting to the underlying concept, just to the Rube-Golbergesque set of unnecessary pipes and shell calls to perform that concept. Most of it can be done in procmail without much trouble, I think.
Okay. After a lot of head scratching I came up with the following. It _is_ tested and appears to work fine. My value of fine includes: Mutt 1.5.16, FreeBSD 6STABLE, procmail v3.22 and setting SHELL to /bin/sh in my procmailrc file (my login shell is zsh 4.3.4, but I prefer to use the FreeBSD Bourne shell derivate with procmail). :0 * some-regexp { TRAP='mv ${LASTFOLDER} ${LASTFOLDER%%new/*}cur/${LASTFOLDER##*/}:2,S' :0 some-folder/ } Is that what you were alluding to? Cheers, Nick. --

On Fri, Aug 03, 2007 at 02:47:29PM +0100, N.J. Mann wrote:
Dallman Ross wrote:
N.J. Mann wrote Thursday, August 02, 2007 6:52 PM:
Actually, I think Michelle may be correct, but I haven't tested the recipes posted by Michelle.
I wasn't objecting to the underlying concept, just to the Rube-Golbergesque set of unnecessary pipes and shell calls to perform that concept. Most of it can be done in procmail without much trouble, I think.
Okay. After a lot of head scratching I came up with the following. It _is_ tested and appears to work fine. My value of fine includes: Mutt 1.5.16, FreeBSD 6STABLE, procmail v3.22 and setting SHELL to /bin/sh in my procmailrc file (my login shell is zsh 4.3.4, but I prefer to use the FreeBSD Bourne shell derivate with procmail).
:0 * some-regexp { TRAP='mv ${LASTFOLDER} ${LASTFOLDER%%new/*}cur/${LASTFOLDER##*/}:2,S'
:0 some-folder/ }
Is that what you were alluding to?
That is very good, and I had also thought of that in answer to the OP whom I sort of lambasted last week. (Btw, my goal was not to drive him away. I apologize if that was the result.) I was going to show a shell-only manner of getting his var as well as the sed, awk, and cut versions I did show, but I ran out of time. -- dman

On 2-Aug-2007, at 09:57, Dallman Ross wrote:
Well, gee, Kreemy. We discussed it a couple or three years ago when you were on the list.
Well, I've only been using maildir for a few months myself.
LASTFOLDER knows where in the maildir hierarchy the file was saved and what its name is. Maildir uses that :2,F thing on the end to mark messages read. Voila.
where's that documented? I thought everything used Status: RO I mean, the message that I mark witha Status: RO are showing up as read, even in maildirs. -- "Queen Isabella and King Ferdinand kicked 200,000 Jews out of Spain, one of the first acts of the Spanish Inquisition, which no one ever expects. " John Carroll's 21st Annual Xmas Quiz answers

In message <99830CDF-F53E-4140-B8CB-F0E8B84ED275@kreme.com>, LuKreme wrote:
On 2-Aug-2007, at 09:57, Dallman Ross wrote:
Well, gee, Kreemy. We discussed it a couple or three years ago when you were on the list.
Well, I've only been using maildir for a few months myself.
LASTFOLDER knows where in the maildir hierarchy the file was saved and what its name is. Maildir uses that :2,F thing on the end to mark messages read. Voila.
where's that documented?
See my reply to Dallman's message.
I thought everything used Status: RO
According to google "Status: RO" is MUA specific. Of course not all information found by google'ing can be trusted. :-( The site I mentioned in my reply to Dallman does not mention anything about it, so I'm not sure if it is even valid (for some value of valid) for maildir mailbox format. I've been using maildir for years and I always thought that to mark a message as read you had to move it from the "new" directory to the "cur" directory - something that I forgot in my haste to reply to the original question! I did remember that you had to rename the file, but I even got that wrong. :-( Cheers, Nick. --

Hello Nick, Am 2007-08-02 19:44:41, schrieb N.J. Mann:
I thought everything used Status: RO
According to google "Status: RO" is MUA specific. Of course not all information found by google'ing can be trusted. :-( The site I mentioned in my reply to Dallman does not mention anything about it, so I'm not sure if it is even valid (for some value of valid) for maildir mailbox format. I've been using maildir for years and I always thought that to mark a message as read you had to move it from the "new" directory to the "cur" directory - something that I forgot in my haste to reply to the original question! I did remember that you had to rename the file, but I even got that wrong. :-(
Short explanation to "Read" and "Old" messages on Maildir: I am using fetchmail and procmail since ages plus courier-imap. Some time ago I was accessing the Maildirs over NFS directly with mutt since it is times faster... So, if a messsage was coming in, it is going into ~/Maildir/.folder/new/1234567890.12345_0.samba3 ^^^ Now accessing the folder =.folder/ using directaccess will show the message in "mutt" as NEW. If you leave the folder, it will normaly (if you use standard settings for mutt "mark_old=yes") moved and renamed to ~/Maildir/.folder/cur/1234567890.12345_0.samba3:2, ^^^ ^^^ and the next time it show up as "Old" otherwise it stay as ~/Maildir/.folder/new/1234567890.12345_0.samba3 ^^^ OK, Accessing the same file ~/Maildir/.folder/new/1234567890.12345_0.samba3 ^^^ using IMAP, courier-imap will MOVE the file immediatly to ~/Maildir/.folder/cur/1234567890.12345_0.samba3:2, ^^^ ^^^ and courier write the entry into ~/Maildir/.folder/courierimapuiddb as I have already described in the previos mail. Now accessing the folder =.folder/ using IMAP will show the message in "mutt" as NEW. If you leave the folder, it will be leaved untouched (if you use standard settings for mutt "mark_old=yes") Using "mark_old=no" leave it untouched and it mutt will recognize this folder always with NEW messages. OK, now reading the message will rename it to: ~/Maildir/.folder/cur/1234567890.12345_0.samba3:2,S ^^^ ^^^^ So, if you using "courier-imap" with "mutt" and do not want to mark the messages "only as old" you need to update courierimapuiddb. Thats the different accessing the Maildir "local" or over "courier-imap" Please note, that I am subscribed to over 1300 Packages from the Debian- BTS and I do not realy want to walk through 2000 messages per day... So I use "TRAP" and a script which "READ" the messages for me... Greetings Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ ##################### Debian GNU/Linux Consultant ##################### Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSN LinuxMichi 0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)

On Wed, 8 Aug 2007, Michelle Konzack wrote:
Hello Nick,
Am 2007-08-02 19:44:41, schrieb N.J. Mann:
I thought everything used Status: RO
According to google "Status: RO" is MUA specific. Of course not all [..]
Short explanation to "Read" and "Old" messages on Maildir:
[...]
Good article Michelle! Thanks, Udi
Greetings Michelle Konzack

Am 2007-07-30 18:51:30, schrieb N.J. Mann:
I use the following to set the "flagged" flag:
:0 * my-regexp-here { TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,F' } :0 my-maildir-mail-box/
It works like a charm. To mark the mail as READ rather than "flagged" the filename extension should be R rather than F, i.e.
{ TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,R' }
but I haven't tested this.
It should be: ----8<---------------------------------------------------------- :0 * my-regexp-here { :0fw |formail -I Status: RO TRAP='mv $LASTFOLDER ${LASTFOLDER}:2,S' :0 my-maildir-mail-box/ } ----8<---------------------------------------------------------- and since he use Maildir-Format, ${LASTFOLDER} should be ----8<---------------------------------------------------------------- :0 * my-regexp-here { :0fw |formail -I Status: RO TRAP='mv $LASTFOLDER `echo ${LASTFOLDER} |sed 's|/new/|/cur/|'`:2,S' :0 my-maildir-mail-box/ } ----8<---------------------------------------------------------------- And if you do not want o be bothered by mutt using courier-imap, you must put `echo ${LASTFOLDER} |sed 's|/new/|/cur/|'`:2,S' also in ${FOLDER}/courierimapuiddb which has the format: 1 ${UNIX_SERIALDATE} ${N+3} N+1 ${filename},S=xxxx N+2 ${filename},S=xxxx which mean, you have to update 1. The ${UNIX_SERIALDATE} using `date +%s` 2. Adding the new filename with size as N+3 3. increasing the number ${N+3} to ${N+4} 4. touching the FOLDER with the same time of the ${INIX_SERIALDATE} and now, courier-imap will never know, that you have fooled it... :-) Since it is a little bit more complex, I would it pack into a SHELL script and call it with TRAP='fool_courier ${LASTFOLDER}' Greetings Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ ##################### Debian GNU/Linux Consultant ##################### Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSN LinuxMichi 0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
participants (6)
-
Dallman Ross
-
LuKreme
-
Michelle Konzack
-
N.J. Mann
-
Sebastian Krohn
-
Udi Mottelo