The situation is as follows:
I am trying to send out multipart/alternative email in plaintext and html with no attachments. I have everything working just fine except for opening the file containing html and php (in this case named .php to pass variables using include()), passing the variables, and then formatting as plaintext (stripping out HTML, and PHP tags). This is the first time around trying to send out multipart/alternative and not wishing to use any external classes. So far I have the following:
below is the file being opened using fopen at "templates/email.php"
<html>
<head>
</head>
<body>
<h3 style="color:#d31e47;">Password Reset</h3>
<p>You received this e-mail because you reset your password for our website.</p>
<p>Your login information is:<br>
Email: <strong><?PHP echo $to; ?></strong><br>
Temporary Password: <strong><?PHP echo $p; ?></strong></p>
<p>To log in to our ftp site, click on the following link:<br>
<a href="http://somesite.com/" target="_blank">somesite.com</a></p>
<p>Thank You,</p>
<p>Some Company</p>
</body>
</html>
$html = 'templates/email.php';
$search = array ('@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@([\r\n])[\s]+@', // Strip out white space
'@&(quot|#34);@i', // Replace HTML entities
'@&(amp|#38);@i',
'@&(lt|#60);@i',
'@&(gt|#62);@i',
'@&(nbsp|#160);@i',
'@&(iexcl|#161);@i',
'@&(cent|#162);@i',
'@&(pound|#163);@i',
'@&(copy|#169);@i',
'@&#(\d+);@e'); // evaluate as php
$replace = array ('',
'',
'\1',
'"',
'&',
'<',
'>',
' ',
chr(161),
chr(162),
chr(163),
chr(169),
'chr(\1)');
ob_start();
$file = @fopen($html, 'rb');
$text = fread($file, filesize($html));
$code = str_replace('<?php', '<?', $text);
$code = '?>' .$text. '<?';
$temp = eval($code);
$temp = preg_replace($search, $replace, $temp);
$temp = ob_get_contents();
$body .= "{$temp}\n\n";
fclose($file);
$temp = NULL;
ob_end_clean();
The code is outputting the contents of the php file with variables eval'd but not stripping any tags. I have tried removing $temp = ob_get_contents() and it sends nothing.
If anyone could shed any light on this it is extremely appreciated. Thanks.