如何使用phpmailer并从ckeditor以html格式发送邮件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何使用phpmailer并从ckeditor以html格式发送邮件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1592字,纯文字阅读大概需要3分钟。
内容图文
![如何使用phpmailer并从ckeditor以html格式发送邮件](/upload/InfoBanner/zyjiaocheng/684/72b7640a40094607b76c1b87987b3a2e.jpg)
我使用phpmailer发送电子邮件,在ckeditor表单上插入html代码的内容时遇到问题,但数据仅发送到电子邮件文本.
这是我的代码:
require_once ('class.phpmailer.php');
$mail = new PHPMailer(true);
if (isset($_POST['btn_send']))
{
$smtp_username = strip_tags($_POST['username']);
$smtp_password = strip_tags($_POST['password']);
$ssl_port = strip_tags($_POST['port']);
$my_smtp = strip_tags($_POST['host']);
$my_ssl = strip_tags($_POST['type']);
$realname = strip_tags($_POST['realname']);
$subject = strip_tags($_POST['subject']);
$body = strip_tags($_POST['editor']);
$emaillist = strip_tags($_POST['emaillist']);
//...now get on with sending...
try
{
//$mail->isSendmail();
$mail->isSMTP();
$mail->Body = ($body);
$mail->isHTML(true);
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "$my_ssl";
$mail->Host = "$my_smtp";
$mail->Port = "$ssl_port";
$mail->AddAddress($emaillist);
$mail->Username = "$smtp_username";
$mail->Password = "$smtp_password";
$mail->SetFrom("$smtp_username", "$realname");
$mail->AddAddress($emaillist);
$mail->epriority = "3";
$mail->AddReplyTo("$smtp_username");
$mail->Subject = "$subject";
$mail->encode = ("yes");
$mail->CharSet = "utf-8";
if($mail->Send())
{
$msg = "<div class='alert alert-success'>
Hi,<br /> bro mail terkirim ke ".$emaillist."
</div>";
}
}
catch(phpmailerException $ex)
{
$msg = "<div class='alert alert-warning'>".$ex->errorMessage()."</div>";
}}
我不知道出了什么问题
解决方法:
您需要编辑此行
$body = strip_tags($_ POST [‘editor’]);
到$body = $_POST [‘editor’];
并在邮件发送之前添加此行
$mail-> isHTML(true);
函数strip_tags删除html标记.
但是您还需要另一种过滤器值.
内容总结
以上是互联网集市为您收集整理的如何使用phpmailer并从ckeditor以html格式发送邮件全部内容,希望文章能够帮你解决如何使用phpmailer并从ckeditor以html格式发送邮件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。