2

I have a 5GB mailbox which I moved using imapsync. But somehow I messed up with --delete/--delete2 option and end up with almost all the messages having \Deleted flag set. I do not have delayed expunge enabled, so I can not use unexpunge utility. I am using cyrus-imapd v2.3.7. Using cyrus-imapd's debugging feature I found out that email client(Roundcube in my case) fires following IMAP command to unset it.

UID STORE 179 -FLAGS.SILENT (\Deleted)

I don't know if somehow I can fire this command for all the mails.

Is there any way I can unset \Deleted flag for all the mails in the mailbox?

UPDATE:

Using @geekosaur's tip of specifying range of message-ids in the above command, I could solve it for one mailbox under INBOX like INBOX.folder1. Is there any way I can do it for multiple mailboxes under INBOX recursively? Now I am working on solving it using/creating some script, maybe using Perl's IMAP related module. But still I need to solve it asap so inputs are welcome.

UPDATE:

Thanks to geekosaur, I succeeded in solving it using Perl's IMAPClient module.

1 Answer 1

1

You can specify a range of messages start:end in place of the single message number (179 in your example); use SEARCH ALL to find out the valid message number range.

Note, this is assuming you can use raw IMAP, which can be painful to impossible if it is (as it should be) using AUTHENTICATE instead of LOGIN.. You may prefer to find an IMAP toolkit of some kind (note that Cyrus imapd comes with Perl libraries that can be used to script logging in and performing various operations, although you will need to have some familiarity with RFC 2060.

5
  • thanks a lot, you have saved my day. By specifying range I could solve it for one of the mailbox under INBOX. I have multiple mailboxes under INBOX like INBOX.folder1, INBOX.folder2 etc. Is there any way to use this functionality recursively? Apr 9, 2012 at 3:15
  • Not with the standard IMAP protocol; you need to SELECT each folder individually.
    – geekosaur
    Apr 9, 2012 at 3:17
  • thanks for your tips. I have started working on it. Still I am keeping the question open for some time. Apr 9, 2012 at 4:03
  • 1
    Unfortunately, as presently designed the protocol doesn't really support multifolder operations (note how the notion of current folder is built into the protocol, and how hierarchy is kinda hacked in with various special flags in LIST etc.). IMAP is overdue for a redesign for better multifolder support, but various proposed extensions for it have languished.
    – geekosaur
    Apr 9, 2012 at 4:12
  • thanks geekosaur, I succeeded in solving it using Perl's IMAPClient module. I will soon post my solution on my blog sachintech.net and post the link here. Apr 10, 2012 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .