luckypower has asked for the wisdom of the Perl Monks concerning the following question:

Hellow monks,

i am working on imap migration.
but when i use Mail::IMPAClient's migrate method, it will throw an error.

here is my code
1 #!/usr/bin/perl -w 2 3 use strict; 4 use Mail::IMAPClient; 5 6 my $from = Mail::IMAPClient->new( Server => $ser1, 7 User => $usr1, 8 Password => $pass1 9 ); 10 my $to = Mail::IMAPClient->new( Server => $ser2, 11 User => $usr2, 12 Password => pass2 13 ); 14 15 $from->select("INBOX.Mymails"); 16 $from->migrate($to, 31, "INBOX.Mymails");

the error is
Use of uninitialized value in string eq at /usr/lib/perl5/vendor_perl/ +5.8.8/Mail/IMAPClient.pm line 773, <STDIN> line 2. Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/ve +ndor_perl/5.8.8/Mail/IMAPClient.pm line 773, <STDIN> line 2.

the mymails folder is present in both mailbox.
the version of module is 3.08.


Thanks in advance
Lucky

Replies are listed 'Best First'.
Re: Problem in mail migration
by Anonymous Monk on Nov 07, 2008 at 07:32 UTC
Re: Problem in mail migration
by gone2015 (Deacon) on Nov 07, 2008 at 12:14 UTC

    Well, looking at Mail::IMAPClient.pm on CPAN I find that v3.08 contains:

    756 # Get the "+ Go ahead" response: 757 my $code = 0; 758 until($code eq '+' || $code =~ /NO|BAD|OK/) 759 { 760 my $readSoFar = 0; 761 my $fromBuffer = '';; 762 $readSoFar += sysread($toSock, $fromBuffer, 1, $readSoFar +) || 0 763 until $fromBuffer =~ /\r\n/; 764 765 $code = $fromBuffer =~ /^\+/ ? $1 766 : $fromBuffer =~ / ^(?:\d+\s(BAD|NO))/ ? $1 : 0; 767 768 $peer->_debug("$folder: received $fromBuffer from server" +); 769 770 # ... and log it in the history buffers 771 $self->_record($trans, [0, "OUTPUT", 772 "Mail::IMAPClient migrating message $mid to $peer->User +\@$peer->Server"] ); 773 $peer->_record($ptrans, [0, "OUTPUT", $fromBuffer] ); 774 }
    so, line 765 will set $code to undef if $fromBuffer does start with '+', which will generate the warnings you are seeing -- reported against the last (significant) line of the until because... because that's what it does.

    The latest version is v3.11, and is similarly flawed. It is dated 08-Oct-2008, so at least it appears to be "live". Suggest you take this up with the author via http://search.cpan.org/~markov/Mail-IMAPClient-3.11/lib/Mail/IMAPClient.pod.