在PHP中为电子邮件消息加下划线

时间:2018-03-11 13:47:53

标签: php

我需要在使用PHP mail()函数发送的电子邮件中强调某些字词或将其粗体化。例如,$message = "_Posted By: _";$message = "(u)Posted By: (/u)";或$message = "(strong)Posted By: (/strong)";不起作用。

任何建议都将非常感谢!

P.S。我在这些示例中使用括号而不是标记来阻止它们在此问题中以粗体显示。

1 个答案:

答案 0 :(得分:2)

在标题中将内容类型设置为HTML:

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

在邮件中使用html标记:

$message = "<b>Posted By: </b>";

使用标题发送邮件:

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

您还可以从w3cschools.com查看example # 3以了解详情