【问题标题】:Working with Twig and PHPMailer使用 Twig 和 PHPMailer
【发布时间】:2014-07-07 11:19:47
【问题描述】:

我正在开发一个使用 Twig 和 PHPMailer 的网站。当系统发送电子邮件时,我希望该电子邮件的正文为 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 文件

【问题讨论】:

    标签: php html css twig phpmailer


    【解决方案1】:

    使用 render() 代替 display()

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-23
      • 1970-01-01
      • 2021-12-10
      • 2017-11-18
      • 2014-10-26
      • 1970-01-01
      • 2018-03-15
      • 1970-01-01
      相关资源
      最近更新 更多