in reply to
Mail::IMAPClient wont get messages
Although IMAP::Client works quite well on its own, you may
consider to use Mail::Box as abstraction level. Mail::Box supports various folder formats and hides implementation differences. See its website.
You can simply use messages on the remote IMAP4 server as if they are local.
my $f = Mail::Box::IMAP4->new(host => ..., username => ...,
password => ..., folder => ...) or die;
foreach my $msg ($f->messages) ...
$f->message(3)->head->add('X-Handler' => 'my own');