I'm trying to send HTML content through PHP mail() function. I don't know what is wrong with my code. I tried many ways, spent hours. but, nothing worked out. Can anyone tell me what is wrong with my code, please?
<?php
$to = "shakthik92@gmail.com";
$today = date("Y/m/d");
$today = $today." 00:00";
$count_cash_inc = mysql_query("SELECT sum(income) as inc, sum(expense) as exp FROM journal_entry WHERE `date` >= '$today'");
$inc = mysql_fetch_array($count_cash_inc);
$income_c = $inc['inc'];
$epense_c = $inc['exp'];
$counter_cash = $income_c - $epense_c;
$subject = "Daily Report From Sri Sankalpa";
$headers = "From: info@srisankalpa.com\r\n";
$headers .= "Reply-To: info@srisankalpa.com\r\n";
$headers .= "CC: admin@srisankalpa.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message = '<center><h1>Sri Sankalpa Daily Journal Report</h1>';
$message .= '<br><table><tr><td>Date</td><td>Total Income</td><td>Total Expense</td><td>Balance</td></tr>';
$message .= '<tr><td>'.date("d-m-Y").'</td><td>'.$income_c.'</td><td>'.$epense_c.'</td><td>'.$counter_cash.'</td></tr></table><br>';
$message .= '<p>To Know More... Please Click <strong><a target="_blank" href="http://srisankalpa.com/demo/journal_entry.php">HERE</a></strong></p></center>';
mail($to, $subject, $message, $headers);
?>
I tried removing \r,\r\n and changing charset=UTF-8 to charset=iso-8859-1. But nothing works. Looking forwarded for your help. Mail sending perfectly as a plain text without the below line
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";