i have a basic perl script that creates an email and forwards it. i would like to add something to this script that will remove ALL headers from any email that it forwards. i am a super newb to perl so any help would be awesome. here is my script:
#!/usr/bin/perl use CGI ':standard'; use CGI::Carp qw(fatalsToBrowser); ######################## Program Header ############################## +########### ## ## Copyright (C) 2004 Poetic Pollution ## Script Name: BareBonesMailer ## Version: 0.2.4 ## URL: http://poeticpollution.net/scripts/BareBonesMailer/ ## ## This program is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License ## as published by the Free Software Foundation; either version 2 ## of the License, or (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## Please read the full GNU GPL: http://www.gnu.org/copyleft/gpl.html ## ###################################################################### +########### ######################## User Defined Variables ###################### +## ## Edit as needed... # Path to sendmail $mailProg = "/usr/sbin/sendmail -t"; # Your email address and be sure to leave the \ in front # of the @ or else you'll get errors.. ;) $toEmail = "you\@yourdomain.com"; # Domains that are able to use the mailer script # Enclose in quotes and seperate each with a comma @valid_referrers = ("yourdomain.com","yourotherdomain.com"); # Redirect them to this URL: # This should be a pre-existing file with a thank you # message or something similar.. $redirectURL = "http://www.yourdomain.com/thanks.html"; # Your time zone difference from GMT $offSet = "-7"; # Military time 0 = off 1 = on $milTime = 0; ######################## Engage Mailer ######################## ## Don't Edit Below Here Unless You Know How... $valid_http_referrer = 0; foreach(@valid_referrers) { if($ENV{'HTTP_REFERER'} =~ /^https?:\/\/(www\.)?$_/i) { $valid_http_referrer = 1; last; } } unless($valid_http_referrer) { &headerFooter; print qq|You are coming from the wrong page. Please go back and tr +y again..\n|; print @footer; exit; } $fromName = param('nameField'); $fromEmail = param('emailField'); $formContents = param('formField'); $formSubject = param('Subject'); unless($fromName) { &headerFooter; print qq|The <b>Name</b> field is required. Please go back and try + again..\n|; print @footer; exit; } unless(($fromEmail) && ($fromEmail =~ /.*\@.*/)) { &headerFooter; print qq|The <b>Email</b> field is required. Please go back and tr +y again..\n|; print @footer; exit; } unless($formContents) { &headerFooter; print qq|You must include a message of some sorts. Please go back +and try again..\n|; print @footer; exit; } @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @time = gmtime(time + (3600 * $offSet)); $newMinSec = sprintf("%02d:%02d",$time[1],$time[0]); $newDay = sprintf("%02d",$time[3]); $years = $time[5] + 1900; if ($milTime) { $hours = sprintf("%02d",$time[2]); } else { if ($time[2] < 12) { if ($time[2] == 0) { $hours = 12; } else { $h +ours = $time[2]; } $amPm = " AM"; } else { if ($time[2] > 12) { $hours = $time[2] - 12; } else { $hour +s = $time[2]; } $amPm = " PM"; } } $dateFormat = "$newDay/$months[$time[4]]/$years at $hours:$newMinSec$a +mPm"; $remoteAddress = $ENV{'REMOTE_ADDR'}; $remoteHost = $ENV{'REMOTE_HOST'}; @subnetNumbers = split (/\./, $remoteAddress); $packedAddress = pack ("C4", @subnetNumbers); ($remoteHost) = gethostbyaddr ($packedAddress, 2); open(MAIL, "|$mailProg") || die "Unable to open Mail Program."; print MAIL "To: $toEmail\n"; print MAIL "From: $fromEmail\n"; print MAIL "Subject: $formSubject\n"; print MAIL "Date: $dateFormat.\n\n"; print MAIL "Name: $fromName <$fromEmail>\n"; print MAIL "$remoteHost / $remoteAddress\n"; print MAIL "Browser: $ENV{'HTTP_USER_AGENT'}\n"; print MAIL "Subject: $formSubject\n\n"; print MAIL "$formContents\n"; close(MAIL); print "Location: $redirectURL\n\n"; exit; sub headerFooter { # ------------------------------------------------ open (FILE, "mailer-template.html") || die "Unable to open the Mailer +Template for reading.."; @HTMLFile = <FILE>; close(FILE); for ($a = 0; $a < @HTMLFile; $a++) { if ($HTMLFile[$a] =~ /<!-- mailer + output will be here -->/) { $foundIt = 1; last; } } unless($foundIt) { die "HTML comments not found in the Mailer Template +.."; } for ($i = 0; $i < $a; $i++) { push(@header, $HTMLFile[$i]); } for ($i = $a; $i < @HTMLFile; $i++) { push(@footer, $HTMLFile[$i]); } print "Content-type: text/html\n\n"; print @header; }

In reply to Removing Headers in Perl by North323

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.