Page 1 of 1

include a seperate php file in email sent from script

Posted: Wed Jul 11, 2007 2:26 am
by dvgreen1
Sorry - newbie here.

I have a php script that sends an email. I want the body of the email to be the details that are presented normally when another script is called.

eg: in the script I have the following:

Code: Select all

tep_send_mail('$to_name', '$to_address', '$subject, '$body', $from, $from_address);
which is the following:

TO NAME, TO EMAIL ADDRESS, EMAIL SUBJECT, EMAIL CONTENTS, FROM NAME, FROM EMAIL ADDRESS

$body is a script (lets call body.php)

How can I do this?

Posted: Wed Jul 11, 2007 2:50 am
by Gente
fopen() or file_get_contents() with URL of your script as parameter

email include

Posted: Wed Jul 11, 2007 2:58 am
by dvgreen1
hey thanx for getting back to me so quick

sorry to be a PITA

but something like this?

Code: Select all

tep_send_mail($to_name, $to_address, $subject, fopen(otherfile.php), $from, $from_address);

or do I need to define it first like:

$body = fopen(otherfile.php);

tep_send_mail($to_name, $to_address, $subject, $body, $from, $from_address);
assuming the otherfile.php is in the same directory? or something similar

eg: can you spell out for me line by line?

... told you I was a newbie

Posted: Wed Jul 11, 2007 3:03 am
by Gente

Code: Select all

<?php
$handle = fopen("http://www.example.com/body.php", "rb");
$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);
tep_send_mail($to_name, $to_address, $subject, $contents, $from, $from_address); 
?>