Subject: | accessing messages on an IMAP server by message number |
Date: | Thu, 18 Aug 2016 12:29:36 +0200 |
To: | Perl Beginners <beginners [...] perl.org>, bug-Mail-IMAPClient [...] rt.cpan.org |
From: | hw <hw [...] gc-24.de> |
Hi,
how can I access messages residing on an IMAP server by their
message numbers? "Message number" means what MUAs like the
one built into Seamonkey display as 'Order received'.
The IMAP server being used is cyrus, and the message number
corresponds to the name of the file the message is stored in.
IIRC, these numbers never change unless you run some program
that comes with cyrus to re-number the messages.
According to the documentation, Mail::IMAPClient[1] can use
message numbers to access messages, but it does not work in that
it accesses messages that have different numbers than the number
given as parameter to a function Mail::IMAPClient provides.
For example:
$imap->migrate($targetaccount, 25, $targetfolder);
... copies *a* message (apparently a randomly selected one), but
not the message that has the number 25.
I have no good way to identify messages other their file names and
thus the message numbers derived from them because the virus scanner
gives me the file names. I can not simply delete the files because
that would screw up the indices and/or whatever cyrus uses to manage
the messages.
Since it´s not feasible to tell the users that they need to delete a
message with a particular number, I´ve written a program to delete
(quarantine, actually) the messages the virus scanner thinks contain
viruses. It turns out that my program does not work because messages
are quarantined apparently randomly, and the messages that contain the
viruses remain untouched. I can even run it several times to quarantine
the same messages, and it will quarantine another message every time,
though the message numbers used are the same each time :(
So either Mail::IMAPClient is buggy, or it uses some other, useless way
to enumerate the messages by itself rather than using the message numbers
the IMAP server uses.
(And yes, the UId is set to 0, and I verified that it remains 0.)