in reply to Retrieving email and decoding attachments
BTW, this was done hastily and could use more error testing, could probably be done more simply/elegantly, but I leave that for the poster.#!/usr/local/bin/perl use strict; use warnings; use Mail::POP3Client; use MIME::Parser; my $pop = new Mail::POP3Client( USER => "user", PASSWORD => "password", HOST => "pop3.server" ); ## for HeadAndBodyToFile() to use my $fh = new IO::Handle(); ## Initialize stuff for MIME::Parser; my $outputdir = "./mimemail"; my $parser = new MIME::Parser; $parser->output_dir($outputdir); my $i; ## process all messages in pop3 inbox for ($i = 1; $i <= $pop->Count(); $i++) { open (MAILOUT, ">pop3.msg$i"); $fh->fdopen( fileno( MAILOUT ), "w" ); ## write current msg to file $pop->HeadAndBodyToFile( $fh, $i ); close MAILOUT; ## MIME::Parser handles only one msg at-a-time open (MAILIN, "<pop3.msg$i"); ## flush all attachments this msg to ./mimemail dir using internal +filename my $entity = $parser->read(\*MAILIN); close MAILIN; }
Does anyone know how to read the messages directly to MIME::Parser without having to write the intermediate files first? I've encountered this dilemma recently trying to combine other unrelated mail modules.
--Jim
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Retrieving email and decoding attachments
by Anonymous Monk on Jun 13, 2007 at 19:44 UTC | |
by unrelatedmonk1 (Novice) on Jul 20, 2015 at 20:20 UTC | |
Re^2: Retrieving email and decoding attachments
by Anonymous Monk on Dec 05, 2012 at 05:25 UTC |