doupu5941 2015-07-01 07: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 05: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.

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部