dongmei8511 2014-12-14 07:42
浏览 36
已采纳

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

I have created a contact me page that uses CK Editor to edit the content of the mail. I am using xampp/ localhost to test the mail. I want the mail to be exactly like i edit it in the editor

For example the bold part in editor doesnot show up bold in the mail it is sent as

<strong>SOMETHING IN BOLD</strong>

How do i use CK editor or any other so that the mail is sent as

SOMETHING IN BOLD

and not as shown above.

Thank you.

HTML Code

<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 Code

<?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
Email: $senderEmail
About Sender: $senderAbout
Title: $title

$message";

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

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

?>
  • 写回答

1条回答 默认 最新

  • doucaishou0074 2014-12-14 07:48
    关注

    Looks like you're not sending an HTML-header with the email. Here you can see how you can do this: (example 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" . "
    ";
        $headers .= "Content-type:text/html;charset=UTF-8" . "
    ";
        $headers .= "From: $sender <$senderEmail>" . "
    ";
    
        mail($recipient, $subject, $mailBody, $headers);
    
        // ...
    }
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题