my %mail =
(
"To" => "$__to",
"Subject" => "$__subject",
"Content-Type" => $__content_type,
);
And you didn't really show us where the values of those scalars are coming from. Which means that these hash elements might never have had any line termination characters of any kind (in which case your substitutions would do nothing at all), or if they did have CR and/or LF, you might be screwing things up by having any sort of line-termination characters at all in those header values (this seems more likely).
You might want to try this (if you haven't already):
for ( $__to, $__subject, $__content_type, ... ) {
tr/\r\n/ /;
s/\s+$//;
}
my %mail =
(
"To" => $__to,
"Subject" => $__subject,
"Content-Type" => $__content_type,
);
That will tell you whether Mail::Sendmail does the right thing in terms of appending CRLF at the end of every header field. If those strings already have CR and/or LF in them, you are probably asking for trouble. Ideally, Mail::Sendmail would be smart enough to make sure that any header field value does not contain either CR or LF before the module itself appends CRLF to each header field for output. (Having spurious CR and/or LF scattered around in the header fields is a Bad Thing.)
As for the message body, I'd be inclined to try something like this:
my @message_lines =
( '', # blank line
'This is a multi-part message in MIME format.',
'','', # a couple blank lines
"------=$_random_boundary",
..., # i.e. one array element for every line of message content
'','' # including a couple blanks at the end
);
my $_mail_message = join( "\r\n", @message_lines );
My apologies for giving bad advice earlier (adding "\r" to the header fields) -- I should have known better. |