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 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败