-1

现在我将所有信息存储到一个变量中

$email_body = "";
$email_body = $email_body . "<b>Name:</b>" . $name . "\n";
$email_body = $email_body . "E-mail:" . $email . "\n";
$email_body = $email_body . "Phone Number:" . $phnum . "\n";
$email_body = $email_body . "Message:" . $message . "\n";

$messageSend = $email_body;

mail($to,$subject,$messageSend,$headers);

如何添加 html like <br/><b>tag 和 css?

4

2 回答 2

2

附加到标题Content-Type,如

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

并附加消息<html><body></body></html>喜欢

$email_body = '<html><body>';
$email_body .= "<b>Name:</b>" . $name . "\n";
$email_body .= "<b>E-mail:</b>" . $email . "\n";
$email_body .= "<b>Phone Number:</b>" . $phnum . "\n";
$email_body .= "<b>Message:</b>" . $message . "\n";
$email_body .= '</body></html>';
于 2013-08-06T06:36:09.360 回答
0

"\n" 在 html 中不起作用使用这样的 "paragraph" 标签

$email_body = "<html><body>";
$email_body .= "<b>Name:</b>" . $name . "<p>";
$email_body .= "<b>E-mail:</b>" . $email . "<p>";
$email_body .= "<b>Phone Number:</b>" . $phnum . "<p>";
$email_body .= "<b>Message:</b>" . $message . "<p>";
$email_body .= "</body></html>";
于 2013-08-06T06:56:28.917 回答