【问题标题】:how can i style a sending email with inline css [duplicate]如何使用内联 css 设置发送电子邮件的样式 [重复]
【发布时间】:2018-01-30 10:43:55
【问题描述】:

我正在使用一个表单来让我的客人订阅我即将推出的网站。

我的问题是我真的不知道如何使这封电子邮件具有一些 css 样式。我尝试了内联 CSS,但没有任何反应。我收到的电子邮件只是显示样式代码,并没有将其转换为 html!

我使用的代码是这样的:

<?php

if(isset($_REQUEST["isvalid"])){

$youremail = "info@mywebsite.com;

$usersemail = $_POST["usersemail"];

$mailsubject = "You have a new subscriber";


$message ="
<div style='width:300px;padding:20px;margin:0 auto;background:#84C318;color:#ffffff;border-radius:3px;'>
Email Address: $usersemail
</div>
"; 

$headers = 'From:' . $usersemail . "\r\n";
mail($youremail, $mailsubject, $message, $headers);
echo "success";

} else {
echo "failed";
} 

?>

我不确定,但我认为我可以在变量中添加内联 css 样式。我也尝试将内联样式移到变量之外,但得到了相同的结果。

在这里需要一些帮助..

【问题讨论】:

    标签: php css html-email


    【解决方案1】:

    您需要通过将 Content-type 标头设置为“text/html”来指定您的电子邮件是 html 电子邮件。

    更多信息在这里:https://css-tricks.com/sending-nice-html-email-with-php/

    【讨论】:

      猜你喜欢
      • 2015-10-09
      • 2018-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-29
      • 1970-01-01
      • 2015-02-19
      • 1970-01-01
      相关资源
      最近更新 更多