Javascript PHP邮件功能不工作。。!

Javascript PHP邮件功能不工作。。!,javascript,php,mysql,Javascript,Php,Mysql,实际上,我使用的是LOCALHOST。我已经创建了一个表单,允许访问者通过电子邮件与我联系。我正在使用PHP邮件功能,但它不工作。错误是else语句中提到的 HTML <form id="contact" method="post" action="contact us.php"> <h1>Contact us</h1> <label for="subject">Subject:(required)</lab

实际上,我使用的是
LOCALHOST
。我已经创建了一个表单,允许访问者通过电子邮件与我联系。我正在使用PHP邮件功能,但它不工作。错误是else语句中提到的

HTML

<form  id="contact" method="post" action="contact us.php">
        <h1>Contact us</h1>
        <label for="subject">Subject:(required)</label>
        <input type="text" name="subject" placeholder="Enter your subject.." required/></br>
        <label for="email">E-mail:(required)</label>
        <input type="email" name="email" placeholder="Enter your email.." required/></br>
        <label for="website">Website:(optional)</label>
        <input type="url" name="website" placeholder="Enter your website.."/></br>
        <label for="message">Message:(required)</label>
        <textarea placeholder="Enter your message.." required="required" rows="12" name="message"></textarea></br>
        <input type="submit" name="send" value="Send message"/>
    </form>

您必须在本地计算机上设置邮件服务器或使用
smtp
lib发送电子邮件 或者只是 在本地计算机上安装
Sendmail
,然后使用SMTP详细信息更改配置

smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password

我必须在中更改设置

php.ini

现在代码运行成功。

如果您试图在本地工作,您已经做了一些设置。代码似乎很完美,请在服务器上检查一个。我希望它也能用于检查垃圾邮件和垃圾。

您正在调用
mail()
两次。检查此链接可能有助于您查看http服务器错误日志文件。在这里,您可以真正了解问题的具体内容,而不必猜测。根据您的回答(应该是编辑),您的本地主机上似乎没有安装SMTP服务器,这使我认为您正在Windows上运行此服务器。更新php.ini以指向实际的SMTP服务器,或者安装一个。
smtp_server=smtp.gmail.com
smtp_port=465
auth_username=user@gmail.com
auth_password=your_password
php.ini