如何使用CKEditor发送精确编辑的文本

时间:2014-12-14 07:42:34

标签: php email ckeditor

我创建了一个联系我页面,它使用CK编辑器编辑邮件内容。我正在使用xampp / localhost来测试邮件。我希望邮件与我在编辑器中编辑它完全一样

例如,编辑器中的粗体部分不会在邮件中显示为粗体

<strong>SOMETHING IN BOLD</strong>

如何使用CK编辑器或任何其他编辑器以便将邮件作为

发送

大胆地出现

而不是如上所示。

谢谢。

HTML代码

<form action="upload.php" method="post" style="height:100%">

                <input name="articleTitle" value="Title" maxlength="50" 
                id="articleTitle">

                <textarea name="article-body">
                    Compose your article...
                </textarea>

            <script>
                CKEDITOR.inline( 'article-body' );
            </script>

        <br>
                <input name="senderName" type="text" value="Name" maxlength="50" 
                id="name" class="textBox">

                <input name="senderEmail" value="Email address" maxlength="50" 
                id="email" class="textBox">

                <input name="abtyou" value="About Yourself" maxlength="150" 
                id="abtyou" class="textBox">

                <input type="submit" name="submit" class="button">

            </form>

PHP代码

<?php

    $thankYou="";   

if(isset($_POST["submit"])) {
    $recipient="zain.farid@live.com";
    $subject="New Guest Post";
    $sender=$_POST["senderName"];
    $senderEmail=$_POST["senderEmail"];
    $senderAbout=$_POST["abtyou"];
    $message=$_POST["article-body"];
    $title=$_POST["articleTitle"];

    $mailBody="Name: $sender\nEmail: $senderEmail\nAbout Sender: $senderAbout\nTitle: $title\n\n$message";

    mail($recipient, $subject, $mailBody, "From: $sender <$senderEmail>");

    $thankYou="Thank you! Your post has been submitted.";
}

?>

1 个答案:

答案 0 :(得分:0)

您似乎没有通过电子邮件发送HTML标头。在这里,您可以看到如何执行此操作:(示例3)http://www.w3schools.com/php/func_mail_mail.asp

<?php

if(isset($_POST["submit"])) {
    // ... email settings ...

    // Always set content-type when sending HTML email
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $headers .= "From: $sender <$senderEmail>" . "\r\n";

    mail($recipient, $subject, $mailBody, $headers);

    // ...
}

?>