Good day bros. I am trying to get Mail::Sendmail to send a multi-part MIME message containing an HTML and a text version of the same message. I am cribbing code from from the Perl Sendmail FAQ which I have interpreted thus:
sub sendmessage { my ($html,$text,$recipient,$reportdate) = @_; my $boundary = "====" . time() . "===="; my %mail = ( from => 'foo@bar.org', to => $recipient, subject => "A message from me", 'content-type' => "multipart/alternative; boundary=\"$bou +ndary\"" ); my $plain = encode_qp $text; $html = encode_entities($html); $boundary = '--'.$boundary; $mail{body} = <<END_OF_BODY; $boundary Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable $plain $boundary Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable $html $boundary-- END_OF_BODY sendmail(%mail) || die "Error: $Mail::Sendmail::error\n"; return; }
When I run this, it sends the message fine, but when I open the message in Outlook it shows the raw HTML instead of recognizing it as HTML. Here are the relevant header fields from the mail client (with some info starred out to protect the innocent, namely me):
Return-path: <info@*****.org> Envelope-to: corman@*****.com Subject: A message from me Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="====1214608857====" To: corman@*****.com Date: Fri, 27 Jun 2008 17:20:57 -0600 From: info@*****.org
Anybody know what's going wrong here?

Steve


In reply to Mail::Sendmail Multipart MIME isn't working by cormanaz

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.