我通过ajax调用将内容从html发布到php。我想发送一封包含该发布内容的HTML电子邮件。我回应了所有内联CSS的发布数据。但在邮件中,我只能看到没有CSS效果的html内容。Html电子邮件忽略所有内嵌的CSS(已解决)
我的html代码将有一些静态内容与内容可编辑功能。
<form id="form"name="form" method="post" action="xyz.php" onsubmit="this.divcontent.value = document.getElementById('email_body').innerHTML;">
<input type="hidden" name="divcontent" id="divcontent" value="" />
<div id="email_body" class="field" role="textbox" contenteditable="true">
<div style="....">......</div>
<a>.....</a>
<div style="....">....</div>
<div style="....">....</div>
</div>
<div class="send_mail"><button type="submit">Send</button></div>
</form>
我Ajax调用
$.ajax({
type : 'POST',
url : $("#form").attr('action'),
data : fields,
dataType : 'json',
success: function() {......}....});
我的PHP代码与无CSS效果发送邮件。
<?
$email_body = $_POST[divcontent];
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//create email headers
$headers .= 'From: '.$email_from."\r\n".
'Reply-To: '.$emailid_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_body, $headers);
$array = array('error' => false, 'message' => $message);
echo json_encode($array);
echo json_encode($array);
?>
any suggestions?
我在这里没有看到任何内联CSS,你可以显示它应该在哪里? – 2013-05-07 18:41:08
@Pekka 0123'
好的,但我想看到实际的风格 – 2013-05-07 18:42:44