我有这个消息表单提交的问题。我可以将信息发送到。php文件,但邮件没有发送,有人能帮助我吗?
这里是jquery
$('form.contact').on('submit', function() {
var that = $(this),
url = that.attr('action'),
type = that.attr('method'),
data = {};
that.find('[name]').each(function() {
var that = $(this);
name = that.attr('name');
value = that.val();
data[name] = value;
});
$.ajax({
url: url,
type: type,
data: data,
success: function(response) {
console.log(response);
}
});
return false;
});
这里是php
include 'config.php';
// Email Submit
if (isset($_POST['email']) && isset($_POST['name']) && isset($_POST['message'])){
//send email
mail(EMAIL_ADDRESS, "Contact Form: ".$_POST['name'],
$_POST['message'], "From:" . $_POST['email']);
}
EMAIL_ADDRESS
是由管理员设置的常量。
如果需要,这里是html
<div id="contact_form">
<form action="admin/submit.php" method="post" class="contact">
<input class="fullwidth" type="text" name="name" placeholder="Your Name" />
<input class="fullwidth" type="email" name="email" placeholder="Email Address" />
<textarea type="text" name="message" placeholder="Message"></textarea>
<input id="submit" type="submit" value="Submit" />
<div id="submit_triangle"></div>
</form>
</div>
嗯,你的代码看起来很好。但是系统上安装了邮件服务器吗?检查邮件服务器的设置,如果有的话
http://php.net/manual/en/function.mail.php表示,如果邮件被成功接收,则mail
返回TRUE,否则返回FALSE。
重要的是要注意,仅仅因为邮件被接受交付,这并不意味着邮件实际上会到达预定的目的地
如果你能够发送数据到。php,那么它必须是php端,你有困难。通过php.ini打开你的错误处理程序,它应该会告诉你你遇到的是什么php问题。
在包含email函数的php文件中,在脚本的开头添加以下行:
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
//your exiting script //
?>
然后重新运行脚本,如果它仍然不工作,php应该回显php问题供您调试。