HTML 我在localhost xamp下运行代码。它运行良好。 当我上传代码到托管它不工作(不发送邮件).. 我的邮件文件代码没问题。我运行邮件文件单独的邮件文件正在工作。 当我将邮件文件用于ajax 邮件文件时无效...
<div class="col-md-6 contact-bottom bottom-frm-div">
<form action="" method="post" id="cnt-form" class="cnt-form">
<input type="text" value="First Name" name="name" placeholder="" onfocus="this.value='';" onblur="if (this.value == '') {this.value = 'First Name';}">
<input type="text" value="Last Name" name="lname" placeholder="" onfocus="this.value='';" onblur="if (this.value == '') {this.value = 'Last Name';}">
<input type="text" value="Email Address" placeholder="" name="email" onfocus="this.value='';" onblur="if (this.value == '') {this.value = 'Email Address';}">
<textarea placeholder="" name="msg" onfocus="this.value='';" onblur="if (this.value == '') {this.value = 'Message';}">Message</textarea>
<input type="submit" name="send" value="Submit" id="send">
</form>
<div id="loader3" style="display: none;">Success</div>
</div>
的Ajax
$(document).ready(function(){
$(function(){
$('#cnt-form').submit(function(e){
e.preventDefault();
var form = $(this);
var post_url = 'contact-mail-file.php';
var post_data = form.serialize();
$('#loader3', form).html('<img src="https://upload.wikimedia.org/wikipedia/commons/b/b1/Loading_icon.gif" width="100px" /> Please wait...');
$.ajax({
type: 'POST',
url: post_url,
data: post_data,
success: function(msg) {
$(form).fadeOut(800, function(){
form.html(msg).fadeIn().delay(2000);
$('#loader3').show();
});
}
});
});
});
});
PHP邮件文件
<?
if(isset($_POST['send']))
{
$name=$_POST['name'];
$lname=$_POST['lname'];
$email=$_POST['email'];
$message = $_POST['msg'];
$to='inderjeetoffice@gmail.com';
$subject = "Enquiry from Inderjeet - ".date('d F Y h:i:s A');
$from = $email;
$message = '<html><body><table border=0 width=554><tr><td colspan=2><p><b>Enquiry from Setyourbiz</b><br><br></p></td></tr><tr><td colspan=2 class=text4>FORM submitted at '.date('d F Y h:i:s A').'<br></td></tr>
<tr><td width=200 class=text3>Name :</td><td class=text3>'.$name.' '.$lname.'</td></tr>
<tr><td>Email Id :</td><td>'.$email.'</td></tr>
<tr><td>Message :</td><td>'.$message.'</td></tr>
</table></body></html>';
mail( $to, $subject, $message, "From:$from\r\nReply-to:$from\r\nContent-type: text/html; charset=us-ascii", "-f$to" );
$msg=urlencode("Your enquiry has been submitted successfully.");
echo "<script>alert('Your Query is Submited');</script>";
}?>
修改
托管:PHP版本5.4.45
在XAMP中:PHP版本5.6.24
答案 0 :(得分:0)
PHP VERSION请问?
当地和现场?
检查PHPINFO()