我想在 Zend Framework 中制作电子邮件模板。
例如,
<html>
<body>
Dear {$username$},<br>
This is a invitation email sent by your {$friend$}.<br>
Regards,<br>
Admin
</body>
</html>
我想制作这个文件,在 Zend 框架中获取它,设置这些参数(用户名、朋友),然后发送电子邮件。
我怎样才能做到这一点? Zend 支持这个吗?
嗨,这确实很常见。
创建一个视图脚本,例如:/views/emails/template.phtml
<body>
<?php echo $this->name; ?>
<h1>Welcome</h1>
<?php echo $this->mysite; ?>
</body>
创建电子邮件时:
// create view object
$html = new Zend_View();
$html->setScriptPath(APPLICATION_PATH . '/modules/default/views/emails/');
// assign valeues
$html->assign('name', 'John Doe');
$html->assign('site', 'limespace.de');
// create mail object
$mail = new Zend_Mail('utf-8');
// render view
$bodyText = $html->render('template.phtml');
// configure base stuff
$mail->addTo('[email protected] /cdn-cgi/l/email-protection');
$mail->setSubject('Welcome to Limespace.de');
$mail->setFrom('[email protected] /cdn-cgi/l/email-protection','Limespace');
$mail->setBodyHtml($bodyText);
$mail->send();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)