使用 Twig 和 PHPMailer [英] Working with Twig and PHPMailer

查看:44
本文介绍了使用 Twig 和 PHPMailer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个可以使用 Twig 和 PHPMailer 的网络.当系统发送电子邮件时,我希望该电子邮件的正文为 HTML.我必须在电子邮件正文中显示数据.我有文件personal.php,它通过Twig 将数据传递给文件personal.html

$twig->display('Personal.html',array(文本" =>$文本,lenguaje" =>substr($lang, 0, 2)));

如何使用 Twig 传递 HTML 文件?.当我传递数据时,我会

$body = '

<p>'.$this->text['pass_recov_body'].'</p><p><strong>'.$this->text['date_user'].'</strong></p><p><strong>'.$this->text['user'].': </strong>'.$data['txtRecEmail'] .'</p><p><strong>'.$this->text['password'].': </strong>'.$data['txtUsrPass'] .'</p>

';$this->msgHTML($body);

但现在我想通过 CSS 传递一个 HTML 文件

解决方案

使用 render() 而不是 display()

$this->msgHTML($twig->render('Personal.html',array(文本" =>$文本,lenguaje" =>substr($lang, 0, 2))));

I am developing a web that work with Twig and PHPMailer. When the system send a email, I want that email's body to be in HTML. I must show data in email's body. I have the file personal.php that pass data to file personal.html by Twig

$twig->display('Personal.html',array(
    "text" => $text,
    "lenguaje" => substr($lang, 0, 2)
    ));

How I do to pass the HTML file with Twig?. When I pass data I do

$body = '<div>
            <p>'.$this->text['pass_recov_body'].'</p>
            <p><strong>'.$this->text['date_user'].'</strong></p>
            <p><strong>'.$this->text['user'].': </strong>'. $data['txtRecEmail'] . '</p>
            <p><strong>'.$this->text['password'].': </strong>'. $data['txtUsrPass'] . '</p>
        </div>
    ';


    $this->msgHTML($body);

but now I want pass a HTML file with CSS

解决方案

Use render() instead of display()

$this->msgHTML($twig->render('Personal.html',array(
    "text" => $text,
    "lenguaje" => substr($lang, 0, 2)
)));

这篇关于使用 Twig 和 PHPMailer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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