Send a .php page as the body in sendmail?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
fatman
Forum Commoner
Posts: 47
Joined: Fri Jul 21, 2006 11:18 am
Location: Portugal

Send a .php page as the body in sendmail?

Post 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.
Last edited by Benjamin on Fri May 22, 2009 3:30 pm, edited 2 times in total.
Reason: Changed code type from text to php.
anand
Forum Commoner
Posts: 80
Joined: Fri May 22, 2009 11:07 am
Location: India
Contact:

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

Post 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.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

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

Post 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.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

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

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
fatman
Forum Commoner
Posts: 47
Joined: Fri Jul 21, 2006 11:18 am
Location: Portugal

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

Post by fatman »

You are a star! Thank you, it works perfect, first time.
anand
Forum Commoner
Posts: 80
Joined: Fri May 22, 2009 11:07 am
Location: India
Contact:

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

Post by anand »

fatman wrote:You are a star! Thank you, it works perfect, first time.
What you did?
Post Reply