Re: Mail::Box::IMAP4

Mark Overmeer <[email protected]> Wed, 22 Sep 2004 09:27:42 +0200
Newsgroups gmane.comp.lang.perl.modules.mail-box
Organization MARKOV Solutions
Message-ID <[email protected]>
* Tom Allison ([email protected]) [040922 02:58]:
> > I am using HTML::Mason as the basis of an IMAP webclient and was going 
> > to see how well Mail::Box::IMAP4 and HTML::FromMail would fit into this.
> 
> Gosh that was lame.  Sorry I was reading the wrong fine manual...
> 
> bleah!
> But I did get stuck on selecting a folder...
> 
> 
> my $imap = Mail::IMAPClient->new(Server => $client);
> $imap->User($username);
> $imap->Password($password);
> $imap->login;
> print "IsConnected\n" if $imap->IsConnected;
> print "IsAuthenticated\n" if $imap->IsAuthenticated;
> 
> my $folder = Mail::Box::IMAP4->new(imap_client => $imap,
>                                     join_connection => 1);
> 
> print $folder->name;
> 
> Normally this is thought a Mail::Box::Manager:
> my $mgr = Mail::Box::Manager->new();
> my $folder = $mgr->open('INBOX');
> 
> But $mgr assumes mbox format and not an IMAP connection.

The manager is not able to detect automatically that you are talking
about an imap folder: it looks on disk and finds not file nor directory
named 'INBOX', and therefore creates a default folder.

The easiest way to open an IMAP folder would be:

   use Mail::Box::Manager
   my $mgr = Mail::Box::Manager->new();
   my $folder = $mgr->open
     ( 'INBOX'
     , type        => 'imap'
     , password    => 'bar'
     , server_name => 'xyz'
     , server_port => 143
     , username    => 'foo'
     ) or die;

   print $folder->nrMessages;

or even

   my $folder = $mgr->open('imap://foo:bar@xyz:143/INBOX') or die;

should work.
The IMAP client is relatively new, so please don't hesitate to
contact me if you encounter problems. SSL is not supported (yet)
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       [email protected]                          [email protected]
http://Mark.Overmeer.net                   http://solutions.overmeer.net