Subject: | "Can't call method "bodytype" on an undefined value" on Mail::IMAPClient::BodyStructure |
Date: | Fri, 4 May 2012 16:25:45 +0200 |
To: | bug-Mail-IMAPClient [...] rt.cpan.org |
From: | Pierluigi Frullani <pierluigi.frullani [...] frumar.it> |
When using this snippet:
===========================================================
#!/usr/local/bin/perl
use Mail::IMAPClient::BodyStructure;
use Mail::IMAPClient;
my $imap = Mail::IMAPClient->new( Server => "server",
User => "user",
Password => "pwd",
Uid => 1 );
$imap->select("INBOX") or die "cannot select the inbox for $usr: $@\n";
my @recent = $imap->messages or die "Could not messages: $@\n";
foreach my $id (@recent)
{
my $subject = $imap->subject($id);
print $subject."\n";
my $fetched = $imap->fetch($id, "bodystructure");
if (!defined $fetched){
print "Not defined fetched\n";
}
my $struct = Mail::IMAPClient::BodyStructure->new($fetched);
if (!defined $struct){
print "Not defined struct\n";
}
my $mime = $struct->bodytype."/".$struct->bodysubtype;
my $parts =join "\n\t", $struct->parts;
print "Msg $id (Content-type: $mime) contains these parts:\n\t$parts\n";
}
===========================================================
$struct object is always undefined, thus I always get error at:
"my $mime = $struct->bodytype."/".$struct->bodysubtype;"
For what I have seen, in BodyStructure.pm, at line 19, when the parser get called,
it always return undef.
As you can see the $fetched array is defined ( I've put a check for it and is defined ), but the new($fetched) returns undef.
Any idea on what can be ?
I checked against cyrus and exchange 2007 imap servers with same results.
perl -v
This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi
Mail-IMAPClient-3.31 from cpan.org
uname -a
Linux topolinux 2.6.39.3-kdump #8 SMP Thu Feb 23 23:51:30 CET 2012 x86_64 Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz GenuineIntel GNU/Linux
Sorry, not able to patch it ....
Pierluigi