doupu5941 2015-07-01 15:14
浏览 45
已采纳

在PHPMailer上没有通过POST发送Textarea数据

I have a form on my website that is working apart from the textarea data not being sent in the email. The form lets people enter name, email and a message. I receive the email and I get the name and email, but the "message" area is blank.

I have even tried to change the textarea to an input field but not even this is sent in the email? I have no idea why this is not working. Can anyone please help.

Below is HTML form code as well as PHP mail.

HTML

<form enctype="multipart/form-data" method="post" action="php/mail.php" name="cform" id="cform">
    <input name="name" id="name" type="text" class="col-xs-12 col-sm-6 col-md-6 col-lg-6" placeholder="Your name..." >
    <input name="email" id="email" type="email" class="col-xs-12 col-sm-6 col-md-6 col-lg-6 noMarr" placeholder="Your email..." >
    <textarea name="message" id="message" type="text" cols="40" rows="5" class="col-xs-12 col-sm-12 col-md-12 col-lg-12" placeholder="Your message..."></textarea>
    <input type="submit" id="submit" name="send" class="submitBnt" value="Send Message">
</form>

PHP

<?
    require("class.phpmailer.php");

    // form validation vars
    $formok = true;
    $errors = array();

    // sumbission data
    $ipaddress = $_SERVER['REMOTE_ADDR'];
    $date = date('d/m/Y');
    $time = date('H:i:s');

    // form data
    $name = $_POST['name']; 
    $email = $_POST['email'];
    $message = $_POST['message'];

    $mail = new PHPMailer();

    $mail->IsSMTP(); // send via SMTP - mail or smtp.domain.com
    $mail->Host     = "myserver"; // SMTP servers
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "myUsername"; // SMTP username
    $mail->Password = "myPassword"; // SMTP password
    $mail->From     = "myEmail@Address.com"; // SMTP username
    $mail->AddAddress("myEmail@Address.com"); // Your Adress
    $mail->Subject  =  "New contact request from My Website !";
    $mail->IsHTML(true);  
    $mail->CharSet  = 'UTF-8';
    $mail->Body     = "<p>You have recieved a new message from the enquiries form on your website.</p>
                        <p>
                            <strong>Name: </strong>{$name} 
                        </p>
                        <p>
                            <strong>Email Address: </strong>{$email} 
                        </p>
                        <p>
                            <strong>Message: </strong>{$message} // NOT WORKING HERE
                        </p>
                        <p>
                            This message was sent from the IP Address: {$ipaddress} on {$date} at {$time}
                        </p>";

    if(!$mail->Send())
    {
       echo "There was an error... unable to send email <p>";
       echo "Mailer Error: " . $mail->ErrorInfo;
       exit;
    }

    echo "Thank you. Your email has been sent.";
?>
  • 写回答

1条回答 默认 最新

  • douliu3831 2015-07-02 13:44
    关注

    Since the 'message' post parameter is not being received on the server this is a being cleared on the front end. This is probably being caused by javascript validation of the form or any WYSIWYG used to edit the field.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MS中不知道高分子的构型怎么构建模型
  • ¥60 QQOP数据,什么是op数据号,怎么提取op数据!能不能大量提取(语言-c语言)
  • ¥15 matlab代码 关于微分方程和嵌套的分段函数。
  • ¥15 把VMware项目复制到另一台电脑
  • ¥15 onlyoffice编辑完后立即下载,下载的不是最新编辑的文档
  • ¥15 求caverdock使用教程
  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决