Jump to content

Php Output In Html E-Mail


hackalive

Recommended Posts

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

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);

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.