Dear All

I have 2 Pages
smtpAuth.php
contents.php

When I use this code

$body             = file_get_contents('contents.php');
      $body             = eregi_replace("[\]",'',$body);

It cannot show PHP variables values in Send email.
Content.php file attached as contentsphpfile

Whole HTML working fine but PHP DataBase values are not showing in Email.

Recommended Answers

What output you are getting

Jump to Post

Try with php_curl
You must enable php_curl on your server.

then write following function in your smtpauth.php

<?php
function my_curl($url,$rethdr=0)
{
	$ch = curl_init();
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_HEADER, $rethdr);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$res=curl_exec($ch);	
	return $res;
}
?>

$body=my_curl('http://localhost/yourfolder/contents.php',1);

I hope this …

Jump to Post

All 8 Replies

What output you are getting

I am getting everything of HTML tags, but not getting echo Var a; value in my email or even echo this code

$body             = file_get_contents('contents.php');

When I open the contents.php it shows value of a in browser.

Try with php_curl
You must enable php_curl on your server.

then write following function in your smtpauth.php

<?php
function my_curl($url,$rethdr=0)
{
	$ch = curl_init();
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_HEADER, $rethdr);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$res=curl_exec($ch);	
	return $res;
}
?>

$body=my_curl('http://localhost/yourfolder/contents.php',1);

I hope this will work

but i want to know why its not working

Try with php_curl
You must enable php_curl on your server.

then write following function in your smtpauth.php

<?php
function my_curl($url,$rethdr=0)
{
	$ch = curl_init();
	curl_setopt ($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_HEADER, $rethdr);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$res=curl_exec($ch);	
	return $res;
}
?>

$body=my_curl('http://localhost/yourfolder/contents.php',1);

I hope this will work

curl is difficult but my problem is simple, if i use html and php code on smtpauth.php its work fine, but if i get it using get content why its not working

file_get_contents('contents.php'); will only read php file it will not execute php code.

Ok, but if I put my whole contents.php code in the smtpauth.php then it will work fine. but only one problem , its not including image, all other code is working fine
here is code

$body			= "<html><body style='margin: 10px;'>
<div style='width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;'>
<div align='center'><img src='images/phpmailer.gif' style='height: 90px; width: 340px'></div><br>
<table  style='border-color: #666;' cellpadding='10'>
  	<tr>
    <td width='42%' style='background: #eee;'><strong>Total Days</strong></td>
    <td width='58%' style='background: #eee;'><strong>No. of Payments</strong></td>
	</tr>
	
	 	<tr>
    <td width='42%' style='background: #eee;'>15-21</td>
    <td width='58%'>$num_rows</td>
	</tr>
	
		 	<tr>
    <td width='42%' style='background: #eee;'>21-30</td>
    <td width='58%'>$num_rows</td>
	</tr>
	
		 	<tr>
    <td width='42%' style='background: #eee;'>30+</td>
    <td width='58%'>$num_rows</td>
	</tr>

</table>
<br />
Engineering Database:<br />
Generated Automatically by Engineering Databse<br />
Please, DO NOT Reply to this System Generated Email.<br /></div></body></html>";

<?php
<img src='<?php echo "http://".$_SERVER["HTTP_HOST"]."/yourfolder/images/phpmailer.gif" ?>' style='height: 90px; width: 340px'>

?>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.