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 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥15 python天天向上类似问题,但没有清零
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?