Jump to content


Photo

Need Help with Sending HTML Email


  • Please log in to reply
2 replies to this topic

#1 webproclaim

webproclaim
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 09 May 2006 - 09:20 PM

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

?>

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 09 May 2006 - 09:57 PM

Try this:
ob_start();
require("receiptcode.php");
$msg = ob_get_contents(); 
ob_end_clean();


#3 webproclaim

webproclaim
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 10 May 2006 - 01:32 AM

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) View Post[/div][div class=\'quotemain\'][!--quotec--]
Try this:
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