in reply to email output using HTML format.

This will probably scare you, but i'd rather show someone the right way than the "just get it done" way. You don't have to use HTML::Template, you can still use your $myInfo variable, but do consider using MIME::Lite.

use strict; use warnings; use MIME::Lite; use HTML::Template; my $t = HTML::Template->new(filehandle => \*DATA); $t->param( field => 'foo', data => 'bar', ); my $msg = MIME::Lite->new( From =>'me@myhost.com', To =>'you@yourhost.com', Subject =>'Hello HTML', Data => $t->output, # you can just use $myInfo here instead Type =>'text/html', ); $msg->send; __DATA__ <html> <body> <h1>Hello HTML!</h1> <table> <tr> <td><tmpl_var field></td> <td><tmpl_var data></td> </tr> </table> </body> </html>

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: email output using HTML format.
by cees (Curate) on May 09, 2005 at 20:03 UTC

    MIME::Lite (or its cousin MIME::Entity) is definately the way to go here. And if you want to get a little bit fancier, you can provide a text version as well as an HTML version for those of us who hate receiving HTML email.

    $msg = MIME::Lite->new( From => $from, To => $to, Subject => $subject, Type => 'multipart/alternative', ); $msg->attach( Type => 'text/html', Data => $html, ); $msg->attach( Type => 'text/plain', Data => $text, );

    The content type of 'multipart/alternative' tells the browser it can choose between the two formats as they should contain the same information. It means a bit more work for you as you have to format a text version and an HTML version, but it will make your users happy.

    - Cees

Re^2: email output using HTML format.
by Anonymous Monk on May 09, 2005 at 18:53 UTC
    Thanks!