Page 1 of 1

Send a .php page as the body in sendmail?

Posted: Fri May 22, 2009 1:43 pm
by fatman
I have an on-line statement that is available to clients. The page is a complex PHP page that calls date from my DB. I am attempting to send the page as an email to my clients using the code below. Basically, I need to call the page as the 'Body' of the mail. Any idea's on how to put the page there?

Code: Select all

<?php
 
$to  = 'my-client@hismail.com' . ', '; // note the comma
 
// subject
$subject = "Hello client!";
 
// message
$message = "I need the .php page here!";
 
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
// Additional headers
$headers .= 'From: My Company <accounts@mysite.com>' . "\r\n";
$headers .= 'Cc: my-boss@mysite.com' . "\r\n";
 
// Mail it
mail($to, $subject, $message, $headers);
 
?>
 
The way it sits here, it works like a charm, without the message body off-course but it sends to the recipient without a problem.

Re: Send a .php page as the body of a mail?

Posted: Fri May 22, 2009 1:50 pm
by anand
Why dont you try this

Code: Select all

// message
 $message = "<iframe src='http://www.example.com/example.php' width=100% frameborder='0'></iframe>"
 
//This will pull up the page in a frame.
use this with HTML header for your message.

Hope this helps you.

Sorry if what I said is wrong.

Re: Send a .php page as the body in sendmail?

Posted: Fri May 22, 2009 1:58 pm
by jayshields
An automated email sent from PHP? You could use file_get_contents(), or just build the email message HTML from the same logic you used to make the website page.

Re: Send a .php page as the body in sendmail?

Posted: Fri May 22, 2009 1:59 pm
by s.dot
You have to generate the contents of the email. This means you will have to have the script's output fed into a variable.. then you can use that variable as the body of the email.

If you don't want to go that route, you can simply include a link to the page as your body.

Re: Send a .php page as the body in sendmail?

Posted: Fri May 22, 2009 2:08 pm
by fatman
You are a star! Thank you, it works perfect, first time.

Re: Send a .php page as the body in sendmail?

Posted: Fri May 22, 2009 2:16 pm
by anand
fatman wrote:You are a star! Thank you, it works perfect, first time.
What you did?