Thanks for your patience. You are correct in your assumptions. There are messages in a temp folder received via Sendmail, that I would like to forward to another account. The messages have not been modified. They are simply directly forwarded. It's basically like an auto forwarding script out of one directory. I'm not sure what the exact format of email messages are in a folder, so I assume each message was its own file. Please correct me on that if I am wrong. I have integrated your code with a modified version of the script I was writing. I'm pretty sure there are things wrong with it so please let me know. =).
use strict; use Cwd; use Lite; use Mail:Audit; my $dirpath; my $divider = 0; my $input; my $mailprog = '/usr/lib/sendmail'; my $recipient= 'recip@email.com'; my $sender = 'jc@email.com'; my $dirpath = '/var/mail/user/temp'; unless ( chdir $dirpath ) #change to directory { exit(0); } unless (opendir( CHANGEME, $dirpath )){ # print "\nCan't open $dirpath. "; exit (0); } #find all directory contents OTHER than those that begin in . my @dirContents = grep !/^\./, readdir(CHANGEME); if(!@dirContents){ # print "No files were found inside $dirpath\n"; exit (0); } #forward each email message to recipient foreach my $dirContent ( @dirContents ) { open (MESSAGE, "$dirContent"); my @message = <MESSAGE>; my $mail = Mail::Audit->new(data => \@message); my $recip = $recipient; $mail->replace_header('To', $recip); $mail->resend($recip); `rm $dirContent`; } closedir ( CHANGEME ); exit (0);
Could this also be done using MIME::Lite? Thanks for the tips!
jc
In reply to Re: Re: accessing mailbox files
by jc23
in thread accessing mailbox files
by jc23
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |