Hi Monks!
I am trying to insert the value of my template file into the value of the email body, how could I do that, I need to send an email with my ".tmpl" file been the body of my email. This is an example, I will be using MIME::Lite to send the HTML email format if you are wondering how. But here is the code you can see it better, I hope, what I am trying to do:
#!/usr/bin/perl use strict; use CGI qw(-oldstyle_urls :standard); use CGI::Carp qw(fatalsToBrowser); use Date::Calc qw( Add_Delta_Days Decode_Date_US Today ); use HTML::Template; my $template = HTML::Template->new(filename => 'email.tmpl'); print "<h3>Email Test</h3>"; my $from = 'test@test.com'; my $to_name = 'Test Form'; my @mail_to = ( 'me@test.com' ); my $subject = "TEST TEMP\n\n"; # template parameters my $f_name = "Joe"; my $date = "02/08/2011"; my $acc = "123455667889"; my $company = "Test Company."; $template->param(f_name => $f_name); $template->param(date => $date); $template->param(acc => $acc); $template->param(company => $company); my $mail_body = $template; # not working, not the right way, still try +ing... sendmail( \@mail_to, $subject, $mail_body, $from, $to_name ); print "\nDONE\n"; __TESTDATA___ This is the email.tmpl file <table width=\"100%\" border=\"0\" bgcolor=\"#ffffff\" cellpadding=\"0 +\" cellspacing=\"0\"> <tr> <td width=\"100%\"colspan=\"2\">&nbsp;</td> </tr> <tr> <td width=\"100%\" colspan=\"2\"><b>Test</b></td> </tr> <tr> <td width=\"30%\">&nbsp;</td><td width=\"70%\">&nbsp;</td> </tr> <tr> <td width=\"30%\">Name:</td><td width=\"70%\"><TMPL_VAR NAME=" +f_name">.</td> </tr> <tr> <td width=\"30%\">EDate:</td><td width=\"70%\"><TMPL_VAR NAME= +"date">.</td> </tr> <tr> <td width=\"30%\">Acc:</td><td width=\"70%\"><TMPL_VAR NAME="a +cc">.</td> </tr> <tr> <td width=\"30%\">Company:</td><td width=\"70%\"><TMPL_VAR NAM +E="company">.</td> </tr> </table>
Thanks for the Help!!!

In reply to HTML Template Help! by Anonymous Monk

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.