I have a php script that makes some MySQL queries that just writes some HTML (with the dynamic data) to a page. What I want to do is send an email with this HTML as the body. Lets say that the HTML code that I want to insert into the body of the email is contained in my_html_script.php
, and I want to send it 2 $_GET
parameters as well to make the dynamic content come out correctly.
I am in the Joomla framework, so the code to send the email looks like this:
$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.";
}
So, basically I need to include the HTML output of my_html_script.php
into the $body
string variable. How do I do this?
Thanks!
You would just declare the variables before this block and use:
ob_start();
include ('my_html_script.php');
$body = ob_get_clean();