【发布时间】:2011-10-05 00:35:57
【问题描述】:
您好,我正在尝试使用 php mailer 类发送 html 电子邮件。问题是我想在我的电子邮件中包含 php 变量,同时使用包含来保持事情井井有条。这是我的 php 邮件程序....
$place = $data['place'];
$start_time = $data['start_time'];
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "You have an event today";
$mail->Body = file_get_contents('../emails/event.html');
$mail->Send(); // send message
我的问题是,是否可以在 event.html 中有 php 变量?我试过这个没有运气(下面是event.html)..
<table width='600px' cellpadding='0' cellspacing='0'>
<tr><td bgcolor='#eeeeee'><img src='logo.png' /></td></tr>
<tr><td bgcolor='#ffffff' bordercolor='#eeeeee'>
<div style='border:1px solid #eeeeee;font-family:Segoe UI,Tahoma,Verdana,Arial,sans-serif;padding:20px 10px;'>
<p style=''>This email is to remind you that you have an upcoming meeting at $place on $start_time.</p>
<p>Thanks</p>
</div>
</td></tr>
</table>
【问题讨论】:
-
如果你把它设为“event.php”,然后为变量正确分隔回声,它会起作用吗?
-
@Aaron 那仍然会简单地获取文件的内容。
include/require是执行 PHP 文件的唯一方法。 -
是的,我想我正在考虑使用 cURL 抓取页面,它应该在目标中执行 php。
-
@Aaron 是的,如果您将它作为远程 URL 进行访问,但它是在它自己的请求中,然后它也是公共的,这意味着您无法访问您已经设置的相同变量并且您必须处理任何可能的注入攻击。