TASdvlper has asked for the wisdom of the Perl Monks concerning the following question:

All

In one of my Perl script, I'm sending email to various people. I'm trying to use html tags in the message part of my email:

<html> <body> .... the message of my email .... </body> </html>
But, when I get my email, I just see the message coming out just as I wrote it, basically it's not interpreting the html tags, they are just coming out as plain text. My email is Microsoft Outlook (just like everybody else who will be receiving my emails). Any thoughts would be greatly appreciated. Thx.

Replies are listed 'Best First'.
Re: Printing email in html format.
by atcroft (Abbot) on Apr 18, 2005 at 17:51 UTC

    The simple answer is that your mail clients are probably interpreting it as text/plain, and you will likely have to set the Content-type for the section. The Mail::Sendmail FAQ comments on this further:

    How to send HTML mail?
    Instead of sending your mail with a Content-type of "text/plain", you send a "multipart/alternative" MIME mail, where one part is "text/plain" (for clients which cannot display HTML) and the other is "text/html".

    There are ways to simplify this if you are absolutely sure everyone can handle HTML email, which are also noted at that same link. Hope that helps.

    Update: 18 Apr 2005
    Fixed link to point to specific subsection of document.

Re: Printing email in html format.
by merlyn (Sage) on Apr 18, 2005 at 18:27 UTC
Re: Printing email in html format.
by jbrugger (Parson) on Apr 18, 2005 at 17:57 UTC
    Did you set the content-type? e.g.
    my $message = "MIME-Version: 1.0\r\n"; $message .= "Content-type: multipart/alternative;"; ... $message .= "To: " . $self->{ToAddress} . "\n"; $message .= "From: " . $self->{FromAddress} . "\n"; if($self->{TextMessage}) { ... $message .= "Content-type: text/plain;\n"; $message .= "charset=\"iso-8859-1\"\n"; $message .= "Transfer-Encoding: 8bit\n\n"; $message .= $self->{TextMessage}."\n"; } if($self->{HTMLMessage}) { ... $message .= "Content-type: text/html;"; $message .= "charset=\"iso-8859-1\"\n\n"; $message .= $self->{HTMLMessage}; } ...
    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.