我想在我的电子邮件内容中以粗体形式发送一些文本。我使用了以下代码
$to = 'some@gmail.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n";
$from = $param['email']; // this is the sender's Email address
$headers = "From:" . $from;
$name = $param['name'];
$subject = "Test";
$message = "message.\n\n"
."<b>Name:</b> ".$name . "\n\n"
."Adress: \n"
.$param['address'] . "\n"
.$param['zip'] . ", "
.$param['postal_area'] . "\n\n"
."E-post: ".$param['email'] . "\n\n\n"
mail($to,$subject,$message,$headers);
我用过<strong>
也代替 <b>
标签,但没有任何效果。
我收到以下格式的邮件:
<b>Namn:</b> some name
Adress:
Borås, Sweden
4837, Boras
E-post: somemail@gmail.com
最佳答案
您正在再次覆盖 header 变量。您需要附加到它。
$headers .= "From:" . $from; //You forgot to concatenate here...
// ---^ //Add the .
关于php - 如何在 PHP mail() 中将文本设为粗体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22060163/