1

私のスクリプトは電子メールを送信しますが、html タグをレンダリングしません。なぜだかわかりません。

$email = $row['email'];

$mail_body = '<html>
<body>

<p>hello,'.$name.'</p>
<p>this is a testing email </p>
<hr />
<p>by server</p>
</body>
</html>';
$subject = "Better website";
$to = "$email";

$headers = "From: mailscript@hotmail.com\r\n";
$headers .= "Content-Type: text/html\r\n";

$mail_result = mail($to, $subject, $mail_body, $headers);
4

2 に答える 2

2

mail()のマニュアルに示されているように、mimeタイプを設定してみてください

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
于 2012-04-04T17:22:49.593 に答える
0

Jrod が既に回答したように、ヘッダーを追加する必要があります

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

しかし、最近、これが私のものを台無しにしていることがわかり、コメントアウトする必要がありました。

$headers  = 'MIME-Version: 1.0' . "\r\n";
于 2012-04-27T23:05:20.027 に答える