in reply to Email modules

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)

Replies are listed 'Best First'.
Re^2: Email modules
by sliver (Initiate) on Aug 24, 2004 at 03:23 UTC
    Hmmmm... Thanks for your suggestion, but I guess I forgot to mention two things. One, I am not running a POP mail server. Two, the email address that is being used does not have a mailbox... its only a pointer to the mail filter script. I do not want to store any incoming emails. Just strip the information I need, perform any needed functions on the information, then send a response to the sender and trash the original email. Also, this needs to be performed as soon as the email is received. Thanks again for your suggestion...
      I suggest you look at the Mail::Box module anyway. It is written in a way that is generic - it asbtracts the Mailbox - and is independent of the transport (which is POP3 in my case).

      You may be able to use the Message and Messager-header objects, or subclass them. Or at least get some ideas on how to structure mail - like I said - this is a very-well designed module, worth a peek.

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