Jump to content

Need Help with Sending HTML Email


webproclaim

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);

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.