Try the Mail::Box modules.

There is a bit of a learning curve, but these are the best-designed and most comprehensive set of mail modules I have found.

sample code I'm working on ...

use strict; use Mail::Box::Manager; use POSIX qw(strftime); # Dont REALLY need this use Date::Parse qw( str2time ); use Date::Manip; my $MailboxManager = Mail::Box::Manager->new; ReadMail('Mailbox-name' ,'PASSWORD' ,'Server_Name.domain.com'); ############################################################# sub ReadMail{ my ($UserName, $Password, $Server) = @_; # User should included domain, and Mailbox info, as required by serv +er. my $POP3InboxFolder = $MailboxManager->open(type => 'pop3' , folder +=>'/' , username => $UserName, password => $Password ,server_name => $Server ,access => 'r', ,fix_header_errors => 1, fixHeaderErrors=> 1) or die "Cannot open POP inbox for '$UserName' on $Server\n"; my $msgCount=0; foreach my $msg ($POP3InboxFolder->messages(-15,-1)){ # Last 15 #$msg->decoded->print(\*STDERR); print "-" x 50 . "\n"; my $head = $msg->head; print "#Msg SENT on ", ($head->timestamp || 'unknown'), " = ", $head->get('Date') , " Interp=", POSIX::strftime(qq(%H:%M %d %b), localtime($head->timestamp)) +, "\n"; print "#RCVD:" , $head->get('Received', 0) , "\n"; foreach(reverse $head->get('Received')){ # Extract the TIME received.. my $Date = &ParseDate( $_ ) or next; print "#Extracted Rcv Date $Date=" . POSIX::strftime(qq(%H:%M %d %b), localtime($Date)) . "\n"; last; } print "#Subject=", $msg->subject , "\n"; my $sender = $msg->sender; $sender and print qq(#Sender:\t) ,$sender->format , qq(\n) ; for ($head->names){ print "#\t$_\t ", $head->get($_), ";\n" ; } print "-" x 50 . " $msgCount\n"; last if $msgCount++ > 18; } }

    Earth first! (We'll rob the other planets later)


In reply to Re: Email modules by NetWallah
in thread Email modules by sliver

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.