Jump to content

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

Edited by hackalive

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.