Sometime on Jul 6, Zachary Buckholz assembled some asciibets to say:

> Does anyone have any pointers on the best way to utilize
> HTML::Template and a mail merge module?

Well, I do this to send out birthday wishes to everyone in my
department, with Cc's to everyone else:

bday.tmpl:
From: <dept_address>
To: <tmpl_loop birthday_kids><tmpl_var address><tmpl_unless __LAST__>,
        </tmpl_unless></tmpl_loop>
Bcc: <tmpl_loop all_kids><tmpl_var address><tmpl_unless __LAST__>,
        </tmpl_unless></tmpl_loop>
Subject: Happy birthday <tmpl_loop birthday_kids><tmpl_var name><tmpl_unless 
__LAST__>, </tmpl_unless></tmpl_loop>

Body of the message here....


bday.pl:
#!/usr/bin/perl -w

use strict;
use HTML::Template;

my $t = new HTML::Template(filename=>'bday.tmpl', loop_context_vars=>1);
# set vars here

open MAIL, "|/usr/sbin/sendmail -t" or die "$!";
print MAIL $t->output();
close MAIL or warn "$!";

__END__

Don't forget the tabs on the line after To and Bcc or sendmail will
think that it's the end of that particular header line.

Philip

-- 
Michael:
        Hi.  I'm Michael Jackson, from The Jacksons.

Homer:  I'm Homer Simpson, from the Simpsons.

                   Stark Raving Dad




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
We have stuff for geeks like you.
http://thinkgeek.com/sf
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to