Re: Smarty way to do email

From: Date: Tue, 14 Jan 2003 07:53:28 +0000
Subject: Re: Smarty way to do email
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7163@lists.php.net to get a copy of this message
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

« previous php.smarty.general (#7163) next »