如何在电子邮件中添加标签?例如,我想加粗我的$ for_pass。任何想法?谢谢
$subject = "Password Recovery";
$message = "Hi! Your member password is <strong>$for_pass</strong>";
$from = "smilepartyplanner2014@gmail.com";
$headers = "From:" . $from;
// send mail
$mail_sent = @mail( $forgot_email, $subject, $message,$headers );
//echo "Thank you for sending us feedback";
?>
<script>
alert("Your password has been sent to your email address. ");
</script>
<?php
答案 0 :(得分:3)
您需要在邮件中发送MIME标头以告知其HTML,如下所示:
$headers = "From:" . $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mail_sent = @mail($forgot_email, $subject, $message, $headers);
答案 1 :(得分:1)
正如您在邮件正文中所说的那样,但您需要在标题
上声明内容类型 ...
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From:" . $from;
邮件正文可以包含您想要的任何内联样式。