Re: Hello and a quick question
"David Golden" <[email protected]> Thu, 13 Dec 2007 18:12:27 -0500
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <[email protected]> |
On Dec 13, 2007 4:46 PM, Kannan Varadhan <[email protected]> wrote: > I am trying to write an imap-client-daemon with the following behaviour: > > imap-connect-to-server(); > imap-select(inbox); > while (1) { > my $msg = get-nextmessage-from-server(); > if ($msg) { > do-work-on-message($msg); > next; > } > imap-expunge(); > imap-idle(); > sleep(60); > } I've been working a little tiny bit with Mail::Box::IMAP4 and I think something along these lines might work (not tested): while (1) { my $imap = Mail::Box::IMAP4->new( username => 'me', password => 'mypass', server_name => 'imap.example.com', folder => "INBOX", access => "rw" ); for my $msg ( $imap->messages ) { # process messages } $imap->write->close; # write will expunge sleep 60; } Unlike your script, this processes all available messages, *then* sleeps. Also, I think you have to reconnect each time through to load up new messages in the folder as I don't think that Mail::Box::IMAP4 supports "update" yet. (I could be mistaken, though.) Good luck, David _______________________________________________ Mailbox mailing list [email protected] http://lists.utsl.gen.nz/mailman/listinfo.cgi/mailbox