我的php发送邮件有以下脚本,但收到错误"无法发送邮件!请检查您的PHP邮件配置。"
<?php
if($_POST)
{
$to_Email = "bruce@webauthorsgroup.com"; //Replace with recipient email address
$subject = 'IFD Derby Submission'; //Subject line for emails
//check if its an ajax request, exit if not
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
//exit script outputting json data
$output = json_encode(
array(
'type'=>'error',
'text' => 'Request must come from Ajax'
));
die($output);
}
//check $_POST vars are set, exit if any missing
if(!isset($_POST["userEmail"]))
{
$output = json_encode(array('type'=>'error', 'input' => 'Input fields are empty!'));
die($output);
}
//Sanitize input data using PHP filter_var().
$user_Email = filter_var($_POST["userEmail"], FILTER_SANITIZE_EMAIL);
//additional php validation
if(!filter_var($user_Email, FILTER_VALIDATE_EMAIL)) //email validation
{
$output = json_encode(array('type'=>'error', 'input' => 'Please enter a valid email!'));
die($output);
}
//proceed with PHP email.
$headers = 'From: '.$user_Email.'' . "\r\n" .
'Reply-To: '.$user_Email.'' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$sentMail = @mail($to_Email, $subject, $user_Firstname, $user_Last, $user_website, $user_address, $user_city, $user_state, $user_zip, $user_Phone, $user_Email, $user_organization, $user_lakename, $user_lakelocation, $user_LMB, $user_SMB, $user_CP, $user_NP, $user_BC, $user_WC, $user_CF, $user_SA, $user_SE, $user_TR, $user_AS, $user_YP, $user_WP,
$user_CU, $user_S, $user_AF, $user_species, $user_derbydate, $user_derbytime, $user_Message, $user_Phone .' -'.$user_Firstname, $headers);
if(!$sentMail)
{
$output = json_encode(array('type'=>'error', 'text' => 'Could not send mail! Please check your PHP mail configuration.'));
die($output);
}else{
$output = json_encode(array('type'=>'message', 'text' => 'Thank you '.$user_Name .'. Your derby will be listed within 24 hours.'));
die($output);
}
}
?>
我有什么遗漏的吗?我正在使用此表单:http://icefishingderbys.com/icefish/form/contact.html