【问题标题】:Is it possible to add CSS in the Mail function in PHP?是否可以在 PHP 的 Mail 函数中添加 CSS?
【发布时间】:2020-10-01 06:29:05
【问题描述】:

我想在Mail函数中添加一些css到这段代码中:

$text .= "<h1>Confirmation Code</h1>";
$text .= "<img src='https://pbs.twimg.com/profile_images/587949417577066499/3uCD4xxY_400x400.jpg'></img>";
$text .= "<h3>This is your confirmation code. Enter it into the text box in World Web. Here is the code: '".$_REQUEST['random_num']."'</h3>";
$text .= "<h4>Thank you for working with WWW. We appreciate the help!</h4>";
$text .= "</body></html>";
$subject = "Confirmation Code";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$to = $_REQUEST['email'];
mail($to, $subject, $text, $headers);

但是当我添加:

style="color: red;"

或者:

style="background-color: blue;"

它出错了。有人知道我如何在 php 中将 css 添加到邮件功能吗?

【问题讨论】:

    标签: javascript php css function email


    【解决方案1】:

    因为您没有转义 " 内的 "

    尝试:

    $text .= "<h1 style='color:red;'>Confirmation Code</h1>";
    //or
    $text .= "<h1 style=\"color:red;\">Confirmation Code</h1>";
    
    

    【讨论】:

      猜你喜欢
      • 2017-12-25
      • 2013-03-10
      • 2020-03-05
      • 1970-01-01
      • 2021-07-18
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 2010-09-14
      相关资源
      最近更新 更多