如何在Zend Framework中制作电子邮件模板? [英] How can I make email template in Zend Framework?

查看:111
本文介绍了如何在Zend Framework中制作电子邮件模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Zend Framework中制作电子邮件模板.

I want to make email templates in Zend Framework.

例如,

<html>
<body>
Dear {$username$},<br>
This is a invitation email sent by your {$friend$}.<br>
Regards,<br>
Admin
</body>
</html>

我要制作此文件,在Zend框架中获取它,设置这些参数(用户名,朋友),然后发送电子邮件.

I want to make this file, get it in Zend framework, set those parameters (username, friend) and then send the email.

我该怎么做? Zend支持吗?

How can I do that? Does Zend support this?

推荐答案

这很常见.

创建一个视图脚本,例如:/views/emails/template.phtml

Create an view script like : /views/emails/template.phtml

<body>
<?php echo $this->name; ?>
<h1>Welcome</h1>
<?php echo $this->mysite; ?>
</body>

以及在创建电子邮件时:

and when creating the email :

// 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('john@doe.com');
$mail->setSubject('Welcome to Limespace.de');
$mail->setFrom('support@limespace.de','Limespace');
$mail->setBodyHtml($bodyText);
$mail->send();

这篇关于如何在Zend Framework中制作电子邮件模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆