Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Using Mail::IMAPClient (code)

by deprecated (Priest)
on Oct 01, 2001 at 21:09 UTC ( #115910=perlquestion: print w/replies, xml ) Need Help??

deprecated has asked for the wisdom of the Perl Monks concerning the following question:

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.

brother dep.

Laziness, Impatience, Hubris, and Generosity.

Replies are listed 'Best First'.
Re: Using Mail::IMAPClient (code)
by blakem (Monsignor) on Oct 02, 2001 at 01:32 UTC
    I can't answer your immediate question, but I can tell you a little trick concerning searching this site.

    If you get sent to an exact match that was not what you were looking for, try adding some gibberish to your query. Instead of searching on 'imap' try 'imap asdf'

    Of course the best answer is to go to super search... 'asdf' is just a quick 'n dirty interface trick.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://115910]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2023-05-30 17:35 GMT
Find Nodes?
    Voting Booth?

    No recent polls found