webproclaim Posted May 9, 2006 Share Posted May 9, 2006 I am trying to send the contents of another PHP via email using teh script below. I am writing an ecommerce system and need to have the store send out an HTML email receipt.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.<?php ini_set("SMTP", "mywebsite.com");$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\" <noreply@mywebsite.com> \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 AREAmail($to,$subject,$msg, $headers);?> Quote Link to comment Share on other sites More sharing options...
alpine Posted May 9, 2006 Share Posted May 9, 2006 Try this:[code]ob_start();require("receiptcode.php");$msg = ob_get_contents(); ob_end_clean();[/code] Quote Link to comment Share on other sites More sharing options...
webproclaim Posted May 10, 2006 Author Share Posted May 10, 2006 That settles it! Today you are officially 'The Man'.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) [snapback]372763[/snapback][/div][div class=\'quotemain\'][!--quotec--]Try this:[code]ob_start();require("receiptcode.php");$msg = ob_get_contents(); ob_end_clean();[/code][/quote] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.