Hey L~R,

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

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.