我有一个 Action ,该 Action 通过布局渲染一些内容。
我实际上想通过电子邮件发送此输出。在Zend框架中实现此目标的最佳方法是什么?
我知道我需要使用Zend_Mail
组件发送电子邮件,但是我不清楚如何将我的操作输出附加到Zend_Mail
。
我已经对ContextSwitch操作助手进行了一些阅读,我认为这可能是适当的,但是我仍然不相信。
我还是Zend Framework的新手。我习惯于使用诸如输出缓冲之类的技术来捕获输出,我认为这不是在Zend中执行此操作的正确方法。
最佳答案
从您的 Controller :
// do this if you're not using the default layout
$this->_helper->layout()->disableLayout();
$this->view->data = $items;
$htmlString = $this->view->render('foo/bar.phtml');
如果从不是Zend_Controller_Action实例的类中执行此操作,则可能必须先创建Zend_view的实例,才能执行此操作:
$view = new Zend_view();
// you have to explicitly define the path to the template you're using
$view->setScriptPath(array($pathToTemplate));
$view->data = $data;
$htmlString = $view->render('foo/bar.phtml');
关于zend-framework - 在Zend Framework中将 Action 呈现为HTML电子邮件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1552629/