i am writing a code for Php
mailer crone job.
email is going and receiving but why i am receiving HTML
code in email. instead of HTML
template.
i also used proper email header and also test on other users email accounts. but same problem printing HTML
code in email.
i also use <html><body><h2>Hello</h2></body></html>
in message instead of template code. but same problem printing <html><body><h2>Hello</h2></body></html>
in email receive.
Php code
//database connection
require_once("include/config.inc.php");
require_once("include/functions.inc.php");
//init function
mailerCrone();
//defined functions
function mailerCrone() {
$site_admin = 'myemail@gmail.com';
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
$headers = "From: " . $site_admin . "
";
$headers .= "Reply-To: ". $site_admin . "
";
$currentdate = date('Y-m-d H:i:s');
//get data to send mails
$getDataTomail = mysql_query("SELECT * FROM sendmails where status = 0 ORDER BY id ASC limit 0,10");
while($resDataTomail = mysql_fetch_array($getDataTomail)) {
$templateId = $resDataTomail['templ_id'];
$dataPreparedId = $resDataTomail['id'];
//get the template data
$getTemplate = mysql_query("SELECT * FROM templates where id = $templateId");
$resTemplate = mysql_fetch_array($getTemplate);
echo $msg = '<html><body>'.$resTemplate['templ_content'].'</body></html>';
//mail($to, $subject, $message, $headers);
$mailResponce = mail($resDataTomail['subs_email'], $resTemplate['templ_name'], $msg, $headers);
if($mailResponce == '1') {
//update status of selected data after send mail
$updateSendMailData = mysql_query("UPDATE sendmails SET status = '1' WHERE id = $dataPreparedId") or die(mysql_error());
}
}
}