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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀