doudou7361 2015-04-21 04:35
浏览 34

PHP邮件表单不会向电子邮件发送输入

I have a mail form that will not submit the input placed into the text area to the e-mail that I have inserted. I am completely new to PHP. This form has worked for me in the past. I am trying to run the form from the freehostia.com server, I have the first upgraded plan which advertises SMTP. Here is my HTML:

<form action="contact.php" method="post">First name:
    <br>
        <input class="A" id="B" type="text" name="name" size="25">
    <br>
        E-mail:
    <br>
        <input class="A" id="A" type="text" name="email" size="35">
        <textarea id="A" name="message" rows="10" cols="50" placeholder="Please provide your information..."></textarea>
    <div>
        <input class="size" type="submit" value="Send!" />
    </div>
</form>

Here's my PHP content:

<?php
    $field_name = $_POST['name'];
    $field_email = $_POST['email'];
    $field_message = $_POST['message'];
    $mail_to = 'XXXX@XX.com';
    $subject = 'MESSAGE FROM SITE VISITOR ' . $field_name;
    $body_message = 'From: '.$field_name."
";
    $body_message .= 'E-mail: '.$field_email."
";
    $body_message .= 'Message: '.$field_message;
    $headers = "From: $email
";
    $headers .= "Reply-To: $email
";
    $mail_status = mail($mail_to, $subject, $body_message, $headers);
    if ($mail_status) { ?>
        <script language="javascript" type="text/javascript">
            alert('Thank you for the message. We will contact you shortly.')
            window.location = 'index.html';
        </script>
<?php }
    else { ?>
        <script language="javascript" type="text/javascript">
            alert('Message failed. Please, send an email to XXXX@XX.com');
            window.location = 'contact.html';
        </script>
<?php } ?>

Everything appears to be in place to me. I can't for the life of me figure out what I have done wrong here.

  • 写回答

2条回答 默认 最新

  • douhan1860 2015-04-21 04:50
    关注

    where is ur '$email' variable in,

    $headers = "From: $email
    ";
    $headers .= "Reply-To: $email
    ";
    

    where it initialized?

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集