我有以下页面来发送新闻通讯。
当我包含工具栏图标中的图像时。它实时正确显示。但是,当我单击“发送”时,电子邮件会收到没有图像的消息。仅显示消息(编辑器格式化的文本正确显示)
我的图片位于此 URL:http://raveen.comlu.com/sport.jpg
我也打印了发送消息后编辑制作的内容; 即使在那里,图像也没有显示在页面上(参见屏幕截图)
我有以下代码;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> A simple page with CKEditor </title>
<script src="ckeditor/ckeditor.js"> </script>
</head>
<body>
<form method="post" action="">
<!-- Create a <textarea> element first -->
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
//replace the <textarea id="editor1"> with a CKEditor instance
CKEDITOR.replace( 'editor1' );
//Retrieve data from CKEditor instance with ID of editor1
var data = CKEDITOR.instances.editor1.getData()
</script>
<input type="submit" name="btnSubmit" value="Send">
</form>
<?php
if( isset($_POST['btnSubmit']) ){
$editor_data = $_POST['editor1'];
echo $editor_data;
$to = "receiver1@yahoo.com, receiver2@gmail.com";
$subject = "Here is the subject";
$message = $editor_data;
$header = "From: Sender Name <senderemail@gmail.com> \r\n";
$header .= "MIME-Version: 1.0 \r\n";
$header .= "Content-type:text/html;charset=UTF-8 \r\n";
$retval = mail( $to, $subject, $message, $header );
if( $retval == true ){
echo "Message sent successfully";
}
else{
echo "Message could not be sent!";
}
}
?>
</body>
最佳答案
编辑器数据中的所有引用都会被转义,因此您可以尝试在 echo $editor_data;
之前添加此行
$editor_data = stripslashes($editor_data);
关于javascript - PHP 和 CKEditor 包含的图像未显示在电子邮件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37527992/