0

私が何をしても、どんなヘッダーを作成しても、うまくいきません。ヘッダー (メッセージ自体内) にコンテンツ タイプを挿入しました。私は狂ってしまう...

PHP バージョン: 5.2.17

マシン: Linux

カーネル バージョン: 2.6.32-46.1.BHsmp (これが重要な場合)

<?php
$headers = "From: <sender@mydomain.com>" . "\n";
$headers .= "MIME-Version: 1.0" . "\n";
$headers .= "http-equiv='Content-Type' content='text/html; charset=iso-8859-1'\r\n";
$emailBody="<html>";
$emailBody .= "<head>";
$emailBody .= "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>";
$emailBody .= "</head>";
$emailBody .= "<body>";
$emailBody .= "Hello Dear, <br><b>Bla Bla</b><br> See you later. <br>Bye.";
$emailBody .= "</body>";
$emailBody .= "</head>";
$emailBody .= "</html>";
mail("<recipient@gmail.com>", "Testing some HTML mail", $emailBody, $headers);
?>

PHP/HTML の専門家が上記のコードをレビューするのを待っています。

どんな助けでも大歓迎です。

どうもありがとう。

4

3 に答える 3

1

代わりに、この形式でヘッダーを設定してみてください。

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
于 2012-06-23T11:06:34.610 に答える
1

これは単に動作します..

$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';



$message = '
<html>
<head>
  <title>Birthday Reminders ...';



$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
于 2012-06-23T11:12:14.857 に答える
0

PHPMailer のようなライブラリを使用する場合は、HTML メッセージの送信が非常に簡単になります。境界文字列やヘッダーなどについて心配する必要はありません。

サンプルコードは次のとおりです。

$mailer = new PHPMailer();
$mailer->IsHTML(true);
$mailer->ContentType = 'text/html';
$mailer->FromName = $from;
$mailer->Subject = $subject;
$mailer->Body = $yourHtmlContent;
$mailer->AddAddress($someRecipientAddress);
$mailer->Send();
于 2012-06-23T11:08:21.153 に答える