Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re: More efficient way to get unseen IMAP messages by mda2
in thread More efficient way to get unseen IMAP messages by captkirk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (4)
    As of 2020-02-18 22:38 GMT
    Find Nodes?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?

      Results (80 votes). Check out past polls.