Mylar Monks,

So I'm using Template Toolkit to output dynamic web pages. So far so good.

I'm adding a "email me my profile info" button. When clicked on, I want to retrieve the user's profile info from teh db, populate an email template, send it to the user via sendmail, then populate a confirmation template and serve it to the user saying "ths info was just emailed to you...".

So I tried ( in pseudo code):

$vars = { image_path => $image_path, data => \%data, }; $subject = "contact info"; $template_file = 'contact_info_email.htm'; $template_1->process($template_file, $vars) || die "Template process failed: ", $template->error(), "\n"; &send_mail_html($email, $from_address, $subject, $template_1); $template_file = 'confirm_contact_info_email.htm'; $template->process($template_file, $vars) || die "Template process failed: ", $template->error(), "\n";
Where &send_mail_html contacins, among other things, the usual:
$to_address = $_[0]; $from = $_[1]; $subject = $_[2]; $content = $_[3]; ..... print MAIL "To: print MAIL "From: $from\n"; print MAIL "Subject: $subject\n"; print MAIL "$content\n";
And it almost works. The user gets an email, and a confirmation page. But with two problems:
  1. The email contents says: "Template=HASH(0x84fbe20)", instead of containing the template
  2. The confirmation page contains both the templates, the email template AND the confirmation template

So, I'm clearly doing somethign wrong. How should I be doing this?

Thanks.




Forget that fear of gravity,
Get a little savagery in your life.

In reply to Template Toolkit: Output one template to Sendmail, another to browser? by punch_card_don

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.