Current location: Hot Scripts Forums » Programming Languages » PHP » PHP mail function and sending php content.


PHP mail function and sending php content.

Reply
  #1 (permalink)  
Old 12-23-05, 11:47 AM
strings6 strings6 is offline
Newbie Coder
 
Join Date: Dec 2005
Location: Fort Myers, FL
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
PHP mail function and sending php content.

Hello,

I have successfully sent text/html emails with the php mail function in the past. An example of this would be:

$message = "<html><body>Hello</body></html>";

mail($email, $subject, $message, $headers)

where I had set one of the headers to have Content-type: text/html

However, I have been unsuccessful at finding an example of how to send an email with the php mail function that has php in the message. What I really want to do is something like this:

$message = "<html><body><?php include 'http://www.mysite.com/mypage.php'; ?></body></html>";

Where mypage.php would be an existing php page.

I tried this with the text/html content-type, but the email came back blank. When I tried Content-type: text/php, then my email actually showed the code, rather than what the code should do.

Anyone know how to do this?

Last edited by strings6; 12-23-05 at 11:50 AM.
Reply With Quote
  #2 (permalink)  
Old 12-23-05, 01:29 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Php script in an email has no practical application. PHP is a language that exists on web servers that have the PHP scripting language interpreter installed. Email clients don''t and can't execute PHP statements. It is true that web servers and email clients can process HTML, but this does not extend to PHP for email clients.

Last edited by mab; 12-23-05 at 01:32 PM.
Reply With Quote
  #3 (permalink)  
Old 12-24-05, 04:23 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
If you want to send a link to your php page, that of course is possible.

If you want to send the HTML output produced by your php page (what you normally see in a browser when visiting your page) in the email, this should be possible. Using the output buffer, you can parse your php page, then get the contents of the output buffer and insert this into the email.
Reply With Quote
  #4 (permalink)  
Old 12-27-05, 07:42 AM
strings6 strings6 is offline
Newbie Coder
 
Join Date: Dec 2005
Location: Fort Myers, FL
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, what I want to do is send the HTML output produced by my php page. I am not sure what you mean by using the output buffer. Could you show me an example of this that is relevant to my email scenario? Thanks in advance if so.
Reply With Quote
  #5 (permalink)  
Old 12-27-05, 08:03 AM
strings6 strings6 is offline
Newbie Coder
 
Join Date: Dec 2005
Location: Fort Myers, FL
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Whoa! Not too tough afterall. I searched for PHP output buffering on Google and found this site:

http://codewalkers.com/tutorials/44/1.html

It walked me through it and it works!

Thanks for the tip mab.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mail() function error <?Wille?> PHP 1 06-20-04 08:45 AM
mail function causes server error thewhiteshadow PHP 1 11-13-03 03:40 PM


All times are GMT -5. The time now is 06:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.