0

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

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

内容.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> 
4

1 回答 1

1

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

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

内容.php

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

手册: http: //php.net/manual/en/function.str-replace.php

于 2013-11-05T23:37:48.927 回答