Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: More efficient way to get unseen IMAP messages

by mda2 (Hermit)
on May 01, 2006 at 02:49 UTC ( #546624=note: print w/replies, xml ) Need Help??


in reply to More efficient way to get unseen IMAP messages

The more eficient is use of STATUS command of imap protocol. But itīs not available on Net::IMAP::Simple...

Can you implement a hack todo it.

1. Examing the protocol:

0 LOGIN mda "xxxxxx" 0 OK LOGIN Ok. 1 STATUS "INBOX" (UNSEEN MESSAGES) * STATUS "INBOX" (MESSAGES 84 UNSEEN 78) 1 OK STATUS Completed. 2 LOGOUT * BYE Courier-IMAP server shutting down 2 OK LOGOUT completed

2. Understanding module struture (and how Net::IMAP implements):

sub login { my ( $self, $user, $pass ) = @_; return $self->_process_cmd ( cmd => [LOGIN => qq[$user "$pass"]], final => sub { 1 }, process => sub { }, ); }
3. Suggested hack:
package Net::IMAP::Simple; sub unseen { my ( $self, $mbox ) = @_; my $unseen = 0; $mbox ||= "INBOX"; $self->_process_cmd ( cmd => [STATUS => "\"$mbox\"" . " (UNSEEN)" ], final => sub { }, process => sub { $unseen = $1 if ( $_[0] =~ /UNSEEN\s+(\d+)/ ); } ); return $unseen; }

4. Resume:
Examine the module options on code and protocol to improve your process ;)

on time Mail::IMAPClient suggest from davidrw implements many others functions...

--
Marco Antonio
Rio-PM

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://546624]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2019-12-06 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (154 votes). Check out past polls.

    Notices?