Subject: | apparent bug in parse_headers with exchange 2003 server |
Date: | Thu, 17 Jan 2008 22:13:57 +0100 |
To: | <bug-Mail-IMAPClient [...] rt.cpan.org> |
From: | "Michiel Steltman" <Msteltman [...] disway.nl> |
Mark,
I'm hesitating to report since I can hardly imagine that I am the only and
first one to find this: there must be a substantial number of people who
have done what I have tried to do.
Anyway, with the risk of getting egg on my face, here is what happens:
parse_headers fails without a LastError against an exchange 2003 server,
same code works fine against a Cysrus imap server
The difference being:
* 372 FETCH (BODY[HEADER.FIELDS (X-Bogosity much stuff etc
mode UID 100905)
Read: 4 OK FETCH completed.
for the exchange server, and
* 372 FETCH (BODY[HEADER.FIELDS (X-Bogosity much stuff etc
)
4 OK Completed (0.000 sec)
for the cyrus server
Here is the relevant code snippet:
#
# Main -
#
print "Connecting to $imhost as user $id \n" if $opt_v;
my $imap = Mail::IMAPClient->new( Server => $imhost,
User => $id,
Password=> $pw,
Peek => 1,
IgnoreSizeErrors => 1,
Debug => $opt_d||0
) or die "Cannot connect to imap server $imhost";
$imap->select($Inbox) or die "Cannot select $Inbox";
my @uids = $imap->search($search) || die "No $search messages: nothing to do
\n";
#
# uids is an array of arryas; msg is array as well
#
for my $msg (@uids) {
print "msg",Data::Dumper::Dumper($msg) if $opt_v;
for my $id (@$msg) {
my $h = $imap->parse_headers($id,
"X-Bogosity","X-Spam-Status","Subject","Reply-to","From")
or die "parse_headers failed for $id: \"" . $imap->LastError .
" \"";
print "hash",Data::Dumper::Dumper($h) if $opt_v ;
----
and the debug output:
------------------
[root@mist imap]# ./st.pl -u mist@xyz.com -p ****** -v -d
Connecting to xxxxx as user mist@xyz.com
Started at Thu Jan 17 22:00:24 2008
Using Mail::IMAPClient version 3.02 on perl 5.008007
Connecting to xxxxx port 143
Connected to xxxxx
Read: * OK Microsoft Exchange Server 2003 IMAP4rev1 server version
6.5.7638.1 ( xxxxxx ) ready.
Sending: 1 LOGIN "mist@xyz.com" *******
Sent 37 bytes
Read: 1 OK LOGIN completed.
Sending: 2 SELECT Inbox
Sent 16 bytes
Read: * 373 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft
$MDNSent)] Permanent flags
* OK [UNSEEN 372] Is the first unseen message
* OK [UIDVALIDITY 6385] UIDVALIDITY value
2 OK [READ-WRITE] SELECT completed.
Sending: 3 UID SEARCH UNSEEN
Sent 21 bytes
Read: * SEARCH 100905 100920
3 OK SEARCH completed.
msg$VAR1 = [
'100905',
'100920'
];
Sending: 4 UID FETCH 100905 BODY.PEEK[HEADER.FIELDS (X-Bogosity
X-Spam-Status Subject Reply-to From)]
Sent 94 bytes
LITERAL: received literal in line * 372 FETCH (BODY[HEADER.FIELDS
(X-Bogosity X-Spam-Status Subject Reply-to From)] of length 322; attempting
to retrieve from the 336 bytes in: X-Bogosity: Unsure, tests=bogofilter,
spamicity=0.501899, version=1.1.5
Subject: Five considerations for upgrading to Exchange 2007
Reply-To:
TechRepublic Webcasts
<CNET_Networks_#3.237736.3931313538363536@newsletters.online.com>
From: TechRepublic Webcasts
<CNET_Networks_Member_Services@newsletters.online.com>
UID 100905)
<END_OF_iBuffer>
Read: * 372 FETCH (BODY[HEADER.FIELDS (X-Bogosity X-Spam-Status Subject
Reply-to From)]
X-Bogosity: Unsure, tests=bogofilter, spamicity=0.501899,
version=1.1.5
Subject: Five considerations for upgrading to Exchange 2007
Reply-To:
TechRepublic Webcasts
<CNET_Networks_#3.237736.3931313538363536@newsletters.online.com>
From: TechRepublic Webcasts
<CNET_Networks_Member_Services@newsletters.online.com>
UID 100905)
Read: 4 OK FETCH completed.
parse_headers failed for 100905: " " at ./st.pl line 112.
[root@mist imap]#
---------------
Best,
Michiel Steltman