为什么这个PHP联系表格没有发送电子邮件?

时间:2015-11-24 09:43:44

标签: php html

这是一个非常基本的问题,但我根本无法弄明白。提交此PHP表单时,它不会发送电子邮件,我也不知道原因。我希望你们能帮忙。

<?php 
if($_POST['submit']){
    $to = "email@email.com";
    $from = $_POST['email'];
    $name = $_POST['name'];
    $subject = "Form submission";
    $message = $name . " wrote the following:" . "\n\n" . $_POST['message'];
    $headers = "From:" . $from;
    mail($to,$subject,$message,$headers);
    echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
    header( 'Location: http://example.com' ) ;
    }
?>


    <container class="form">
      <table class="formtable" align="center">
        <form action="formcontact.php" method="post">
          <tr><td align="center" class="tabletitle">Name:</td></tr><tr class="space"><td align="center"><input type="text" name="name"></td></tr>
          <tr><td align="center" class="tabletitle">Email Address:</td></tr><tr class="space"><td align="center"><input type="text" name="email"></td></tr>
          <tr><td align="center" class="tabletitle">Message:</td></tr><tr class="space"><td align="center"><textarea rows="5" name="message" cols="30"></textarea></td></tr>
          <tr><td align="center"><input type="submit" name="submit" value="submit"></td></tr>
      </table>
    </container>

由于

2 个答案:

答案 0 :(得分:0)

在您的HTML文件中

form action =“” method =“post”

应该做的伎俩(当然,如果你在PHP中包含你的HTML)

答案 1 :(得分:-1)

检查方式:

SELECT TIMESTAMP_FORMAT('1999-12-31T23:59:59','YYYY-MM-DD HH24:MI:SS') FROM ROMAN.EMPLOYEE;