Working with Twig and PHPMailer

对着背影说爱祢 提交于 2021-01-28 18:24:58

问题


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


回答1:


Use render() instead of display()

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


来源:https://stackoverflow.com/questions/23738741/working-with-twig-and-phpmailer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!