"Richard Kurth" <[EMAIL PROTECTED]> wrote:
> This is pretty much what I want to do. I want to have a e-mail script
> in my application and have it so the user can customize the e-mail that
> is sent out in a configure file. Say he wants to send a recurring bill
> to his customers and he wants it to look a certain way. He would design
> the e-mail using placeholders and the it would be processed and the data
> would be filled in. Do you know of any examples of this in any program
> that is out there.

You need to use or build a template engine.  Search google.com for "php
template engine".  Smarty and FastTemplates come to mind.  Or build you own.
All you really need to do is read a template file (using functions like
fopen, fread, while) and replace template variables with their values.  The
easiest way is to make template variables like %%my_var%%, then read each
line of the template file one at a time and use str_replace() to replace
anything matching %%my_var%% with $my_var, looping through all possible
valid template variables (maybe stored in an array) as each line is parsed.
Or if you prefer you can use regular expressions to replace all template
variables with their corresponding PHP variable.  As you loop through each
line and parse it add the parsed line to a string.  When you're done include
the string in a mail() function to email it or use a file function to write
it to a file.

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/

Reply via email to