For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > April 2005 > Re: [SMARTY] lookin for an example using Smarty template fore sending mail









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] lookin for an example using Smarty template fore sending mail
Messju Mohr

2005-04-06, 8:59 pm

On Thu, Apr 07, 2005 at 12:22:12AM +0200, lpenou wrote:
> Hi list,
>
> I'm looking for an example using a template to send an email, best
> will be an HTML + text email
> dis somenone already publish somewhere an example ?


i like the phpmailer for advanced mailing from php. see:
http://phpmailer.sourceforge.net/

with that you only nee $smarty->fetch() to get the rendered template
as a string and assign that as mail-body to phpmailer.

a simple example:

/* here initialize $smarty, assign vars etc. */

require("class.phpmailer.php");

$mail = new PHPMailer();
$mail->Body = $smarty->fetch('html_mail.tpl');
$mail->AltBody = $smarty->fetch('text_mail.tpl');

$mail->AddAddress($to_email, $to_full_name);
if(!$mail->Send()) {
echo "There has been a mail error sending to " . $row["email"] . "<br>";
} else {
// mail was successfully sent.
}


greetings
messju
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com