模板中phpmailer的Echo变量

模板中phpmailer的Echo变量,php,phpmailer,Php,Phpmailer,如何将变量从phpmailer传递到contents.php(模板文件)?我需要传递$email变量 $mail -> msgHTML(file_get_contents('contents.php'), dirname(__FILE__)); contents.php <div> This email was sent by x. <a href="www.x.com/process_contact.php?email="<?php echo $emai

如何将变量从phpmailer传递到contents.php(模板文件)?我需要传递
$email
变量

$mail -> msgHTML(file_get_contents('contents.php'), dirname(__FILE__));
contents.php

<div>
    This email was sent by x. <a href="www.x.com/process_contact.php?email="<?php echo $email ?> Unsubscribe </a>from this email.
</div> 
<div>
    This email was sent by x. <a href="www.x.com/process_contact.php?email=[emailhere]"> Unsubscribe </a>from this email.
</div> 

此电子邮件由x发送。从这封电子邮件。

用电子邮件替换已知标签:

$email = 'your@email.com';
$mail -> msgHTML(str_replace('[emailhere]', $email, file_get_contents('contents.php')), dirname(__FILE__));
contents.php

<div>
    This email was sent by x. <a href="www.x.com/process_contact.php?email="<?php echo $email ?> Unsubscribe </a>from this email.
</div> 
<div>
    This email was sent by x. <a href="www.x.com/process_contact.php?email=[emailhere]"> Unsubscribe </a>from this email.
</div> 

此电子邮件由x发送。从这封电子邮件。

手动:

您不能,不是以您这样做的方式(它不会在contents.PHP中执行PHP,所以它可能不是您想要的)。这里可能有一个更深层次的建筑问题,考虑对你正在尝试的东西做更深入的阐述。do@Pekka웃 这个问题是一个基本问题。我有一个html代码的模板,但在取消订阅的网址,我需要从用户的电子邮件。