Dear Monks,

I've done a search here re forwarding emails, but none of the 4 threads I looked at helped me sufficiently.

I'm a customer of a webhost which uses cPanel, so I can set up an email address which pipes received emails to a program. I'd like to write a perl program to read the email (that works), make some slight changes (I'll handle that later), and forward it to another address (that's where I'm stuck).

So, here's my code so far:

{ local($/) = undef; # Prepare for slurp $mail = <>; # Slurp entire email from stdin } # Modify the email subject, etc # Leave this part to me # Forward the email $recipient = 'me@mydomain.com'; ??? # Not sure how to send $mail as an email

Complex, ain't it?

I've sent email before with MIME::Lite, but that's where I have the body in a separate variable. In this case however, I have the entire email (headers and all) in my variable.

I need to be able to forward any attachments which are in the email.

Also, if possible, I'd like to retain the original sender as the "from" address, but this is not a vital.

What can y'all recommend, to get this working?

Thanks. Terry


In reply to Simple forward of email with minor mods by tel2

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.