Jump to content

Archived

This topic is now archived and is closed to further replies.

webproclaim

Need Help with Sending HTML Email

Recommended Posts

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 AREA

mail($to,$subject,$msg, $headers);

?>

Share this post


Link to post
Share on other sites
Try this:
[code]
ob_start();
require("receiptcode.php");
$msg = ob_get_contents();
ob_end_clean();
[/code]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.