你好,我正在尝试使用 PHP Mailer 类发送HTML邮件。问题是我想在电子邮件中包含PHP变量,同时使用includes以保持组织结构。以下是我的PHP Mailer代码...
$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>
include
/require
是唯一执行 PHP 文件的方法。 - Nicole