Re: [fw-general] Zend_Mime and Zend_Mail with Smarty

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: [fw-general] Zend_Mime and Zend_Mail with Smarty

by Nico Edtinger-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

José de Menezes Soares Neto wrote:
> I would like to use SMARTY to build my email messages. Can I?
> Could someone give me an example of code?

As long as you only want the body in a smarty template it's quite easy:

<?php
$mail = new Zend_Mail();
$tpl = new Smarty();
$tpl->assign($vars);
$mail->setBodyText($tpl->fetch('mail.tpl'));
$mail->setFrom('foo@...', 'Example');
$mail->setSubject('Test');
$mail->addTo('bar@...', 'example');
$mail->send();
?>

nico