如何将变量从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>
答案 0 :(得分:1)
用您的电子邮件替换已知标签:
$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=[emailhere]"> Unsubscribe </a>from this email.
</div>