Perl question
Zbigniew Koziol
zkoziol-Zd07PnzKK1IAvxtiuMwx3w at public.gmane.org
Sun Apr 3 21:07:21 UTC 2005
I never used Mail::Audit.
It is possible that its broken or your attachements are not encoded
according to certain strict rules.
I would do such things without using modules, just by programming
everything from sratch.
Just an idea. Most likely wrong.
zb.
Martin Duclos wrote:
> Hi all,
>
> I know this is a little off topic but I could sure use some help with
> this. I'm trying to take mail messages and parse them one by one form
> different mailboxes. The mail message are all individual message in
> /home/user/Maildir. I want to load the message and then extract all the
> attachments from it to drop them to a directory. What I have to far is
> below. I always get an number of attachments of zero while there are in
> fact multiple attachments in each message. Any ideas would be greatly
> appreceated.
>
> Martin
>
> #!/usr/bin/perl
> use strict;
> use Mail::Audit qw(Attach);
>
> my($srcDir) = "./src";
> my($destDir) = "./dest";
> my($trash) = "./trash";
>
> #sanity check and create if not exist
> die "Source directory isn't valid!" unless -d $srcDir;
> mkdir( $destDir, 0755 ) unless( -d $destDir );
> mkdir( $trash, 0755 ) unless( -d $trash );
>
> my(@allFiles) = <$srcDir/*>;
>
> foreach( @allFiles ){
> if( -f $_){
> print "Processing file $_\n";
> open FILE, $_ or die "Can't open file $_. $!.";
> my(@fileContents);
> while(<FILE>){
> chomp;
> push( @fileContents, $_ );
> }
> foreach( @fileContents ){
> print $_;
> }
> my($mail) = Mail::Audit->new(data=>\@fileContents);
> print $mail->num_attachments . "\n";
> my($attachments) = $mail->attachments;
> foreach( @$attachments){
> $_->save($destDir);
> }
> }
> }
>
>
> --
> The Toronto Linux Users Group. Meetings: http://tlug.ss.org
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
>
--
Zbigniew Koziol, SoftQuake^(tm) Open Source Business Solutions
Web Development, Linux, Web Mail Fax Voice Servers, Networking
Consultations, Innovative Technologies Tel/Fax: 1-416-530-2780
Toronto, Canada, http://www.softquake.ca, info-lcEyp1+e+UdAFePFGvp55w at public.gmane.org
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list