I'm trying to rid myself of windows. In order to do that, I need to have an IMAP client. I dislike all the clients out there (dont want to learn mutt, dont like pine's license, not interested in mailsmith, outlook blows, and so on...), so I decided to write my own.

To my pleasant surprise, there is a module to do the work for me, Mail::IMAPClient. So I've drafted up some working code that does what I want it to, mostly, except I get interesting results.

Here is the code:

36 chomp (my $sel = <>); 37 $imap -> select( $folders[$sel] ); 38 my @range = reverse(1..$folderorder{$folders[$sel]}); # 1.. #o +f msgs 39 40 MAILBOX: for my $count (@range) { # newest to oldest 41 #MAILBOX: for my $count (1..$folderorder{$folders[$sel]}) { 42 my $messageno; 43 my ($from, $to, $sub); 44 my @aRef = $imap -> parse_headers( $count, "Subject", "Date" +, "From", "To", "Cc" ) ; 45 if (! $aRef[0]) { 46 next; 47 } 48 print "[ $count ]\n"; 49 foreach my $header (@aRef) { 50 print map { "$_\t: " .$header -> {$_}[0] ."\n" } sort keys + %{ $header }; 51 $from = @{ $header -> {From} }[0]; 52 $to = @{ $header -> {To} }[0]; 53 $sub = @{ $header -> {Subject} }[0]; 54 } 55 if (not $count % 5 ) { 56 print "-- more or selection --> "; 57 chomp ($messageno = <>); 58 print "\n"; 59 goto MENU if $messageno eq qq{q}; 60 dispatch_message( $folders[$sel], $messageno, $from, $to, +$sub ) if $messageno; 61 } 62 }
Unfortunately, it seems that when I tell it to print the oneth message, I "start" about a month ago. At the moment, the oneth message is from Aug 17 (yes, I've gotten at least 400 messages since then), and it looks fine in outlook.

I'm not certain where to go with this as I dont see too many logic errors. I'd rather not hear stylistic critiques as this was something I whipped up on a Saturday morning and is just a prototype.

Has anyone used this module <!- tilly, you need not answer ->? Can anyone see how I might be skipping a few hundred messages?

One other note, if you enter 'imap' in the straight search it goes to some defective node that should be reaped, but I cant seem to submit it for consideration.

Thanks,
brother dep.

--
Laziness, Impatience, Hubris, and Generosity.


In reply to Using Mail::IMAPClient (code) by deprecated

Title:
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, details, 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, summary, 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.