PHPのmail()関数でHTMLコンテンツを送信しようとしています。自分のコードに何が間違っているのか分かりません。私は時間を費やし、多くの方法を試しました。しかし、何もうまくいかなかった。誰も私のコードで何が間違っているか教えてください。PHP mail()関数がHTMLを送信しない
<?php
$to = "[email protected]";
$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: [email protected]\r\n";
$headers .= "Reply-To: [email protected]\r\n";
$headers .= "CC: [email protected]\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);
?>
\ r、\ r \ nを削除し、charset = UTF-8をcharset = iso-8859-1に変更しようとしました。しかし、何も動作しません。あなたのお手伝いをお待ちしております。以下の行のないプレーンテキストとして完全に送信するメール
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
単純な 'mail()'よりも高度で、簡単にエラーを追跡する[PHPmailer](http://phpmailer.worxware.com/)を使用してください。 –
メールは送信されてもGmailはそれを削除しました(スパム)。これを防ぐには、phpmailerを使用するだけです。 –
このヘッダーを追加します。 '$ headers。= 'コンテンツタイプ:text/html; charset = iso-8859-1 'となります。 "\ r \ n"; ' –