douzhechi2435 2016-11-22 11:00
浏览 40
已采纳

PHP表单不起作用。 电子邮件不发送[重复]

This question already has an answer here:

I have a contact form on my website and it does not seem to be sending emails. It was on a server when I have been testing it.

Here is the form.

    <form  action="" method="post" name="form">
        <input type="text" name="name" />
        <input  type="email" name="email" />
        <textarea name="message" ></textarea>
        <input  name="submit" type="submit" value="Submit">
    </form>

And here is the PHP code.

   <?php
        if(isset($_POST["submit"])){
        if($_POST["name"]==""||$_POST["email"]==""||$_POST["message"]==""){
        echo "Please fill in the contact form";
        }else{

        $to = "example@gmail.com";
        $subject = "Contact Form";
        $name= $_POST['name'];
        $email= $_POST['email'];
        $message= $_POST['message'];
        $headers = "From: example@gmail.com";

        mail($to,$subject,$name,$email,$message,$headers);

        }
        }
     ?>

I have changed my email address to a dummy one there but it does I have not recieved any emails when I do submit this form though.

Thanks in advance! :)

</div>
  • 写回答

2条回答 默认 最新

  • donpvtzuux37724 2016-11-22 11:02
    关注
    <?php
    $to = "somebody@example.com";
    $subject = "My subject";
    $txt = "Hello world!";
    $headers = "From: webmaster@example.com" . "
    " .
    "CC: somebodyelse@example.com";
    
    mail($to,$subject,$txt,$headers);
    
    //syntax mail(to,subject,message,headers,parameters);
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗