php - 如何在 PHP mail() 中将文本设为粗体?

标签 php function email syntax output

我想在我的电子邮件内容中以粗体形式发送一些文本。我使用了以下代码

$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/

相关文章:

python - 解析发件人、发件人和主题的消息

php - 尝试制作自己的 while 循环,就像 Wordpress Loop 一样

javascript - PHP POST 变量值

php - MySQL 无法满足我的需求

PostgreSQL 条件选择

php - 最大附件大小邮件服务

未安装 PHP 解释器 (Linux)

javascript - Ajax 在 IE10 中不触发

angular - 单击 Ngb 模态背景时的函数调用。 Angular 2模态

asp.net - 电子邮件验证链接的生成