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条)

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法