javascript - 是否可以在 PHP 的 Mail 功能中添加 CSS?

标签 javascript php css function email

我想在邮件功能中添加一些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 吗?

最佳答案

因为您没有在 " 中转义 "

尝试:

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

关于javascript - 是否可以在 PHP 的 Mail 功能中添加 CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64146585/

相关文章:

javascript - 检查 jQuery .hover 操作是否已绑定(bind)

php - 如何使用我的函数将单词转换为数字?

php - 正则表达式 PHP,将所有链接与特定文本匹配

javascript - 从 chrome 扩展更改外部 CSS

javascript - 在 Vue 中使用 Vuex 和事件总线

javascript - React.js 应用程序在服务器中作为空白页面打开,而在本地运行良好

javascript - 如何防止用户在不是他们的 'turn' 时激活 jquery 点击功能?

php - 循环语法错误 : unexpected identifier (jquery+html+php) 中的 html 连接

html - CSS - 字体在具有更高 dpi 的设备上显得更粗

javascript - 原型(prototype)库/CSS