#############################################################
sub create_rewritten_message_file {
# Note: I have indication that there's something
# missing from either the way header fields have
# been saved/stored, or else from the particular
# way we're writing new header lines here. The
# indication is this: I'm no longer able to have
# my mail reader detach -attachments-, even though
# their presence is still visible in the end letter.
#
# I've discovered that if I add a leading space on
# the -second- and subsequent header lines, my MIME
# unapcker then handles the message properly -- but
# my mail reader finds it upsetting. I'm guessing,
# then, that a non-visible character belongs in here
# somewhere, perhaps '\r'. That means I've removed
# one or more of those characters, earlier in the
# program, without realizing it or its significance.
# &send_message has already opened TMPMSG.
# We'll write admin information into our new
# rewritten email header, followed by writing
# other key header fields if we have them.
print TMPMSG "Sender: $mail_admin\nErrors-To: $mail_admin\n";
foreach $tag ("Date:","From:","To:","Subject:")
{
unless ((!defined $header{$tag}) || ($header{$tag} eq ""))
{
print TMPMSG "$tag $header{$tag}\n";
print " $tag $header{$tag}\n";
}
}
# Next we'll write less well-known but important
# header fields, if we have those from the original.
foreach $tag ("MIME-Version:","Content-Type:","In-Reply-To:",
"Content-Transfer-Encoding:","X-Mailer:")
{
unless ((!defined $header{$tag}) or ($header{$tag} eq ""))
{
print TMPMSG "$tag $header{$tag}\n";
}
}
# Then we'll add fields we've devised ourselves,
# holding original information as it was before
# we began our rewriting of things.
if ((defined $header{"for"}) && ($header{"for"} ne ""))
{
print TMPMSG "Was-For: $header{\"for\"}\n";
}
foreach $tag ("Was-To:","Was-CC:","Was-Cc:","Was-cc:",
"Was-BCC:","Was-Bcc:","Was-bcc:")
{
if ((defined $header{$tag}) && ($header{$tag} ne ""))
{
print TMPMSG "$tag $header{\"$tag\"}\n";
}
}
# Finally we'll add the requisite blank line that
# denotes "header ends, body begins", and the body.
print TMPMSG "\n$body\n";
} # end of sub create_rewritten_message_file