在php中使用ckeditor发送HTML电子邮件
我正在使用php使用CKEditor发送一封html电子邮件。我可以在收件箱中收到邮件。但格式不正确。我希望我的收件箱中有HTML格式的电子邮件。目前,它正在显示输出窗口中显示的HTML代码。如果有任何问题,您可以帮助我使用PHP发送HTML格式的电子邮件或查看我现有的代码吗?在php中使用ckeditor发送HTML电子邮件,php,html,ckeditor,html-email,Php,Html,Ckeditor,Html Email,我正在使用php使用CKEditor发送一封html电子邮件。我可以在收件箱中收到邮件。但格式不正确。我希望我的收件箱中有HTML格式的电子邮件。目前,它正在显示输出窗口中显示的HTML代码。如果有任何问题,您可以帮助我使用PHP发送HTML格式的电子邮件或查看我现有的代码吗? 请看一下代码及其输出 <script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script> <div class="pa
请看一下代码及其输出
<script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script>
<div class="panel-body">
<?php if (!isset($_POST['email'])) { ?>
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">To</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail3" placeholder="" name="to_email">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Subject</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputPassword3" placeholder="" name="subject_email">
</div>
</div>
<div class="form-group">
<label for="message_email" class="col-sm-2 control-label">Message</label>
<div class="col-sm-10">
<textarea class="form-control" id="message_email" rows="3" name="message_email"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" name="email">Send</button>
</div>
</div>
</form>
<?php
} else {
if (!empty($_POST['to_email'])) {
$message = htmlspecialchars($_POST['message_email']);
$subject = htmlspecialchars($_POST['subject_email']);
$headers = '';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.="From: admin@expertsusa.org";
$email_to = $_POST['to_email'];
echo '<div class="row">';
$html = stripcslashes($message);
if (mail($email_to, $subject, $html, $headers)) {
echo '<div class="col-md-12"> Success :' . $email_to . '</div>';
} else {
echo '<div class="col-md-12"> Fail :' . $email_to . '</div>';
}
echo '</div>';
}
}
?>
<div class="row">
<div class="col-md-5"></div>
</div>
</div><script>
CKEDITOR.replace( 'message_email' );</script>
到
主题
消息
发送
CKEDITOR.replace('message_email');
此代码可以发送任何电子邮件id的邮件,但其输出为:
你好,我在这里
我找到了解决方案,我在这里犯了错误
$message = htmlspecialchars($_POST['message_email']);
应该是
$message = $_POST['message_email'];
使用此$headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
并使用$message
$message = mysql_real_escape_string($_POST['message_email']);
你的问题到底是什么?这个问题中没有问号。我的问题是,为什么这个代码在我的收件箱中显示HTML代码?甚至我也添加了“内容类型:text/html;charset=iso-8859-1'作为标题。为什么不charset=UTF-8
或者干脆删除它呢?开始:如果我传递了静态html值,那么它工作正常。$html=“jaswindersingh”;所以我认为问题出在这里$html=stripcslashes($message)@你能详细说明一下这个问题吗