我有一个 php 脚本,它可以进行一些 MySQL 查询,这些查询只是将一些 HTML(带有动态数据)写入页面。我想要做的是发送一封以这个 HTML 为正文的电子邮件。假设我要插入到电子邮件正文中的 HTML 代码包含在 中my_html_script.php
,我还想向它发送 2 个$_GET
参数以使动态内容正确显示。
我在 Joomla 框架中,所以发送电子邮件的代码如下所示:
$mailer =& JFactory::getMailer();
$sender = $from_email;
$mailer->setSender($sender);
$email = explode(';',$email);
for ($i=0;$i<count($email);$i++){
$mailer->addRecipient(trim($email[$i]));
}
$body = "
";
$mailer->setSubject('This is the subject');
$mailer->setBody($body);
// Optional file attached
//$mailer->addAttachment();
$send =& $mailer->Send();
if ( $send !== true ) {
//die($send->message);
echo "<p>email FAILED".$recip."</p>";
} else {
//mail sent
echo "Emailed successfully.";
}
所以,基本上我需要将 HTML 输出包含my_html_script.php
到$body
字符串变量中。我该怎么做呢?
谢谢!