Need Help with Sending HTML Email
Posted 09 May 2006 - 09:20 PM
In the script below, I need it to go out and get the file 'receiptcode.php', which is a dynamic PHP page that creates an HTML receipt, and email it to the client.
If I use '$msg = include ("receiptcode.php");'. Rather than populating $msg with the contents of receiptcode.php, it actually writes the processed receiptcode.php file onto the page containing the script.
I also tried using '$msg = file_get_contents("receiptcode.php");' and this gets me closer in that it will actually send out the email receipt and does not write out the receiptcode.php file on the page this script is on BUT, it does not process receiptcode.php so I get all the PHP scripts in the email, unprocessed by the server.
I am sure I am just using the wrong function but I just can't seem to find what I am looking for.
Any help would be GREATLY appreciated.
$to = $Email;
$subject = "mywebsite.com";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; ";
$headers .= "charset=iso-8859-1\r\n";
$headers .= "FROM: \"mywebsite.com\" <firstname.lastname@example.org> \r\n";
// THIS IS THE PROBLEM AREA
// RECEIPTCODE.PHP IS DYNAMICALLY POPULATED FROM A DATABASE USING PHP
//$msg = include ("receiptcode.php");
$msg = file_get_contents("receiptcode.php");
$msg = stripslashes ($msg);
// END PROBLEM AREA
Posted 09 May 2006 - 09:57 PM
ob_start(); require("receiptcode.php"); $msg = ob_get_contents(); ob_end_clean();
Posted 10 May 2006 - 01:32 AM
Works like I charm. Thanks so much.
[!--quoteo(post=372763:date=May 9 2006, 09:57 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ May 9 2006, 09:57 PM) [/div][div class=\'quotemain\'][!--quotec--]
ob_start(); require("receiptcode.php"); $msg = ob_get_contents(); ob_end_clean();[/quote]
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users