Working with Twig and PHPMailer


Working with Twig and PHPMailer

我正在开发一个与Twig和PHPMailer一起工作的web。当系统发送电子邮件时,我希望该电子邮件的正文是HTML格式的。我必须在邮件的正文中显示数据。我有文件personal。php通过Twig

将数据传递给文件personal。html
$twig->display('Personal.html',array(
    "text" => $text,
    "lenguaje" => substr($lang, 0, 2)
    ));

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

$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);

但是现在我想传递一个带有CSS的HTML文件

使用render()代替display()

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