我在提交此消息表单时遇到问题。我可以获得要发送到 .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>