Show quoted text> There's actually two issues here.
>
> 1) fetch_hash() seems to fail parsing ENVELOPE field values that have
> certain quote characters in them.
>
> 2) fetch_hash() doesn't return X-SAVEDATE fields as requested.
>
> Attached is the debug output.
> Versions involved are as follows:
> libmail-imapclient-perl 3.25-1
> perl 5.10.1-16
> Debian Squeeze
>
> Here's a snippit from the code:
>
> # Connect ...
> # Fetch mailboxes.
> my @mboxes = $imap->folders() or die("ERROR: Failed to LIST:\n$@\n");
> foreach my $mbox (@mboxes) {
> # Select the mailbox.
> $imap->select($mbox) or die("ERROR: Failed to SELECT \"$mbox\":\n$@\n");
> # Search for UIDs that are marked as deleted.
> my @uids = $imap->search('DELETED');
> if (scalar(@uids) > 0) {
> my $uid_list = $imap->Range(@uids);
> # Get the date info on those uids.
> my @old_uids;
> my @fetch_fields = ('UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE');
> my %old_msg_data = $imap->fetch_hash($uid_list, @fetch_fields)
> or die("ERROR: Failed to FETCH message data on DELETED UIDs $uid_list:\n$@\n");
> print "Found the following DELETED message data:\n", Dumper(\%old_msg_data);
> # Do stuff with that message data ...
In working around this, I found that if instead of the above
$imap->fetch_hash() code I do the following:
my @lines = $imap->fetch($uid_list, @fetch_fields);
Then I get the following problems:
1) Multi-line string literals {nnn} are not replaced and concatenated as
the documentation reports.
2) I can't call the function as shown above, else I get a BAD response
from IMAP (see below). Instead I have to do the following (basically
compose the IMAP message myself):
@lines = $imap->fetch($uid_list, '('.join(' ', @fetch_fields).')');
Show quoted text> }
> }
> # Disconnect ...
>
> Let me know if you need anything else.
>
> Thanks,
> Brian
Sending: 19 UID FETCH 12:13,17 UID X-SAVEDATE FLAGS ENVELOPE
Sent 53 bytes
Read: 19 BAD Error in IMAP command UID FETCH: Invalid arguments.
ERROR: 19 BAD Error in IMAP command UID FETCH: Invalid arguments. at /usr/share/perl5/Mail/IMAPClient.pm line 1457
Mail::IMAPClient::_get_response('Mail::IMAPClient=HASH(0x2922498)', 19, undef) called at /usr/share/perl5/Mail/IMAPClient.pm line 1406
Mail::IMAPClient::_imap_command_do('Mail::IMAPClient=HASH(0x2922498)', 'UID FETCH 12:13,17 UID X-SAVEDATE FLAGS ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 1312
Mail::IMAPClient::_imap_command('Mail::IMAPClient=HASH(0x2922498)', 'UID FETCH 12:13,17 UID X-SAVEDATE FLAGS ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 1488
Mail::IMAPClient::_imap_uid_command('Mail::IMAPClient=HASH(0x2922498)', 'FETCH', '12:13,17', 'UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 2107
Mail::IMAPClient::fetch('Mail::IMAPClient=HASH(0x2922498)', 'Mail::IMAPClient::MessageSet=SCALAR(0x282ffe0)', 'UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE') called at ./dovecot-maintenance-v4.pl line 154
ERROR: 19 BAD Error in IMAP command UID FETCH: Invalid arguments. at /usr/share/perl5/Mail/IMAPClient.pm line 1357
Mail::IMAPClient::_imap_command('Mail::IMAPClient=HASH(0x2922498)', 'UID FETCH 12:13,17 UID X-SAVEDATE FLAGS ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 1488
Mail::IMAPClient::_imap_uid_command('Mail::IMAPClient=HASH(0x2922498)', 'FETCH', '12:13,17', 'UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE') called at /usr/share/perl5/Mail/IMAPClient.pm line 2107
Mail::IMAPClient::fetch('Mail::IMAPClient=HASH(0x2922498)', 'Mail::IMAPClient::MessageSet=SCALAR(0x282ffe0)', 'UID', 'X-SAVEDATE', 'FLAGS', 'ENVELOPE') called at ./dovecot-maintenance-v4.pl line 154
Use of uninitialized value $line in pattern match (m//) at ./dovecot-maintenance-v4.pl line 160.
Use of uninitialized value $line in pattern match (m//) at ./dovecot-maintenance-v4.pl line 160.
Use of uninitialized value $line in concatenation (.) or string at ./dovecot-maintenance-v4.pl line 165.