This topic is locked

Send 'Printer Frindly' page as email body?

7/17/2007 7:42:21 PM
PHPRunner General questions
G
gawde author

Hello Everyone,
Has anyone tried (and been successful) in placing the Printer Friendly page into the body of an html email? I have done this using php output buffering, that utilized customized output from phpRunner 3.1. But I can't seem to find a way to do this with all the new Smarty and template features.
Any pointers would be appreciated.
Greg

S
scy 7/23/2007

Hello Everyone,

Has anyone tried (and been successful) in placing the Printer Friendly page into the body of an html email? I have done this using php output buffering, that utilized customized output from phpRunner 3.1. But I can't seem to find a way to do this with all the new Smarty and template features.
Any pointers would be appreciated.
Greg


Just what I am hoping to achieve also.

G
gawde author 7/23/2007



Just what I am hoping to achieve also.


Hello scy,
I may have an idea on how to approach this. Will be testing my theory today. I will post the solution if I am successful or even only close in case someone else can help.

greg

G
gawde author 7/27/2007

Looks like I have a solution for this question.
The answer is predicated on the use of the php output buffer (ob_ .....) functions to capture and redirect the html results before they are sent to the browser. In my example, the email address is static but you could pass a variable via

SESSION variables or a hidden form field from the sending page.
Basically, create a php file as shown below and link to it (passing any variables if needed). Mine is in the same folder as the output files from PhpRunner for this project. If you place it in a different folder, your include path to ...._print.php will need to change accordingly. The code is below. Good luck. greg
<?php

ob_start();

include("yourtablename_print.php");

$page_content = ob_get_contents();

ob_end_clean();

$emailto = "someone@domain.com";

$emailsubject = "Sample html email";

$headers = 'From: someone else <info@domain.com>' . "\r\n";

$headers .= 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type:text/html;charset=iso-8859-1' . "\r\n";

mail($emailto, $emailsubject, $page_content, $headers );

header("Location : somepage.php");

exit();

?>