hackalive Posted October 21, 2012 Share Posted October 21, 2012 Hi guys, I am using PHPMailer to send emails - however I need to include some ifnromation outpuuted by PHP (i.e, echo etc). Now I know PHP wont work on the email client side - but I need to include this informaiton dynamically. How can I do this? Cheers in advance PS I did try htmlentities around the php output but that didnt work - not did processing the whole message through that (totally broke when doing this). Link to comment https://forums.phpfreaks.com/topic/269734-php-output-in-html-e-mail/ Share on other sites More sharing options...
hackalive Posted October 21, 2012 Author Share Posted October 21, 2012 This is the code for getting the message contents $postdata = http_build_query( array( 'name' => 'MEMEME' ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('contents.php', false, $context); $mail->MsgHTML($result); Link to comment https://forums.phpfreaks.com/topic/269734-php-output-in-html-e-mail/#findComment-1386707 Share on other sites More sharing options...
Christian F. Posted October 21, 2012 Share Posted October 21, 2012 Why not just edit the text in $result as you need? Since PHP is generating and sending that e-mail, you can do whatever you like to the message. Though, that said: What's the purpose of these lines? $postdata = http_build_query( array( 'name' => 'MEMEME' ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('contents.php', false, $context); Or to ask in another way: Why are you doing it like this? Link to comment https://forums.phpfreaks.com/topic/269734-php-output-in-html-e-mail/#findComment-1386712 Share on other sites More sharing options...
hackalive Posted October 21, 2012 Author Share Posted October 21, 2012 Its so I can place the variables (dynamic content) to the corect place within the HTML email (contents.php) There are some echo in contents.php - but these dont work when sending the email Link to comment https://forums.phpfreaks.com/topic/269734-php-output-in-html-e-mail/#findComment-1386716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.