Re: [SMARTY] Re: Smarty way to do email
| From: | Monte Ohrt | Date: | Tue, 14 Jan 2003 15:09:20 +0000 |
| Subject: | Re: [SMARTY] Re: Smarty way to do email | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7173@lists.php.net to get a copy of this message | ||
Do you really need a template for subject and from?
$body = $smarty->fetch('email.tpl');
mail($email_address, $subject, $body, $from);
On Tue, 2003-01-14 at 01:53, André Rabold wrote:
> I have done it this way:
>
> * Create a template for each part of your email (in your case
> "email_subject.tpl", "email_body.tpl" and "email_from.tpl")
> * Code example using the fetch method of Smarty
> <?php
> $smarty = new Smarty();
>
> // Build Subject (assign variables, fetch output, clean up)
> $smarty->assign("subject", $subject);
> // [...]
> $subject = $smarty->fetch("email_subject.tpl"); // get output of template
> $smarty->clear_all_assign(); // clear assigned variables
>
> // Build Body (assign variables, fetch output, clean up)
> $smarty->assign("bodytext", $bodytext);
> // [...]
> $body = $smarty->fetch("email_body.tpl"); // get output of template
> $smarty->clear_all_assign(); // clear assigned variables
>
> // Build From (assign variables, fetch output, clean up)
> $smarty->assign("from", $from);
> // [...]
> $from = $smarty->fetch("email_from.tpl"); // get output of template
> $smarty->clear_all_assign(); // clear assigned variables
>
> mail($email_address, $subject, $body, $from);
> ?>
>
> Ok for you?
> André
>
>
> "Darryl Bleau" <darrylbleau@submersion.com> schrieb im Newsbeitrag
> news:005401c2bb37$54abb610$fa01a8c0@joe...
> I'm sure I read this someplace when I was researching Smarty, but try as
> hard as I can I can't find it. Maybe I was dreaming. Anyway, I'm pretty sure
> there is a 'Smarty' way to send email (as in, template based) but I can't
> remember or figure out how. I want to do something like this:
>
> <?php
> (...code leading up to this...)
> $smart_subject = magic_smarty_function("email_subject.tpl");
> $smart_email = magic_smarty_function("email_body.tpl");
> $smart_from = magic_smarty_function("email_from.tpl");
> mail($email_address, $smart_subject, $message, $smart_from);
> (...more code...)
> ?>
>
> Where the templates would look something like:
>
> <email_subject.tpl>
> {config_load file="site.cfg" section="email"}
> Please verify your {#siteName#} membership.
>
>
> I'm sure you know what I mean. How can I do this? It seems that it should be
> so simple.. and I'm sure I'm missing something.
>
> Darryl Bleau, B.Sc CS
> Creative Director
> Submersion Corporation
--
Monte Ohrt <monte@ispi.net>