[Dovecot] How to set MDNSent flag on a large amount of mails?
Hi,
after having moved a big mail archive to IMAP, I've now got the following problem: The MUA asks to send an MDN on all those old messages that contain the 'Disposition-Notification-To' header when opened. I'd like to set the $MDNSent flag on those (>10000 in a deeply nested directory structure) mails.
After having read http://wiki.dovecot.org/MailboxFormat/Maildir I wrote a script that changed the filename of mails in all directories that contained the header, so that the filename contained a 'b' in the last part of the filename (after the comma), because I found '1 $MDNSent' in Maildir/dovecot-keywords. I then discovered that there can be a 'dovecot-keywords' file in each directory, and all of those files can have different flags in different order.
Do I really need to write a script that evaluates each dovecot-keywords file, figures out which letter corresponds to the flag and rename the files (per directory) accordingly? Isn't there a more simple way?
Patrick.
-- STAR Software (Shanghai) Co., Ltd. http://www.star-group.net/ Phone: +86 (21) 3462 7688 x 826 Fax: +86 (21) 3462 7779
PGP key: https://stshacom1.star-china.net/keys/patrick_nagel.asc Fingerprint: E09A D65E 855F B334 E5C3 5386 EF23 20FC E883 A005
On Wed, 2008-06-04 at 00:33 +0800, Patrick Nagel wrote:
after having moved a big mail archive to IMAP, I've now got the following problem: The MUA asks to send an MDN on all those old messages that contain the 'Disposition-Notification-To' header when opened. I'd like to set the $MDNSent flag on those (>10000 in a deeply nested directory structure) mails. .. Do I really need to write a script that evaluates each dovecot-keywords file, figures out which letter corresponds to the flag and rename the files (per directory) accordingly? Isn't there a more simple way?
How about making your script use IMAP protocol?
1 list "" * 2 select <each mailbox> 3 uid search header Disposition-Notification-To "" 4 uid store <search result as msgset> +flags $MDNSent
Hi,
On Tue, 03 Jun 2008 19:37:50 +0300, Timo Sirainen <tss@iki.fi> wrote:
How about making your script use IMAP protocol?
1 list "" * 2 select <each mailbox> 3 uid search header Disposition-Notification-To "" 4 uid store <search result as msgset> +flags $MDNSent
Thanks, Timo! Never thought of that :)
I'll give it a try tomorrow... netcat would be the bridge between my shell and dovecot then, I guess?
Patrick.
-- STAR Software (Shanghai) Co., Ltd. http://www.star-group.net/ Phone: +86 (21) 3462 7688 x 826 Fax: +86 (21) 3462 7779
PGP key: https://stshacom1.star-china.net/keys/patrick_nagel.asc Fingerprint: E09A D65E 855F B334 E5C3 5386 EF23 20FC E883 A005
On Wed, 2008-06-04 at 01:17 +0800, Patrick Nagel wrote:
Hi,
On Tue, 03 Jun 2008 19:37:50 +0300, Timo Sirainen <tss@iki.fi> wrote:
How about making your script use IMAP protocol?
1 list "" * 2 select <each mailbox> 3 uid search header Disposition-Notification-To "" 4 uid store <search result as msgset> +flags $MDNSent
Thanks, Timo! Never thought of that :)
I'll give it a try tomorrow... netcat would be the bridge between my shell and dovecot then, I guess?
That'll work, I tend to use python because it comes with error checking, you can use http://johannes.sipsolutions.net/files/cleanspam.txt and modify.
johannes
Hi,
On Tue, 03 Jun 2008 19:20:43 +0200, Johannes Berg <johannes@sipsolutions.net> wrote:
On Wed, 2008-06-04 at 01:17 +0800, Patrick Nagel wrote:
I'll give it a try tomorrow... netcat would be the bridge between my shell and dovecot then, I guess?
That'll work, I tend to use python because it comes with error checking, you can use http://johannes.sipsolutions.net/files/cleanspam.txt and modify.
Thanks, Johannes :) My python skills are very limited, but your example script looks straight forward, and the 'difficult' part isn't even needed for my task, so I'll give it a try.
Patrick.
-- STAR Software (Shanghai) Co., Ltd. http://www.star-group.net/ Phone: +86 (21) 3462 7688 x 826 Fax: +86 (21) 3462 7779
PGP key: https://stshacom1.star-china.net/keys/patrick_nagel.asc Fingerprint: E09A D65E 855F B334 E5C3 5386 EF23 20FC E883 A005
--On Wednesday, June 04, 2008 1:17 AM +0800 Patrick Nagel <patrick.nagel@star-group.net> wrote:
I'll give it a try tomorrow... netcat would be the bridge between my shell and dovecot then, I guess?
Another possibility would be to use the c-client library, part of the uw-imap package:
On Tue, 2008-06-03 at 19:37 +0300, Timo Sirainen wrote:
1 list "" * 2 select <each mailbox> 3 uid search header Disposition-Notification-To "" 4 uid store <search result as msgset> +flags $MDNSent
I've once in a while thought about creating a new protocol to make things like these easier. So it wouldn't attempt to replace IMAP (at least initially :) but rather make scripting a lot easier. Perhaps the syntax could be something similar to a programming language. Like:
list("" "*") > ($box) ( select($box) search(header Disposition-Notification-To "") > ($msg) ( store($msg + "$MDNSent") fetch($msg header subject) ) )
Hmm. Or I don't know. Anyone have some great ideas? :) Ideally it should be something command/event-oriented like IMAP, but with ability to pipe command results to other commands (but without allowing infinite loops).
participants (4)
-
Johannes Berg
-
Kenneth Porter
-
Patrick Nagel
-
Timo Sirainen