我的联系表单无效,我无法发送邮件,也没有显示任何错误。
这是我的php文件:
error_reporting(-1);
ini_set('display_errors', 'On');
set_error_handler("var_dump");
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['phone']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));
$phone = strip_tags(htmlspecialchars($_POST['phone']));
$message = strip_tags(htmlspecialchars($_POST['message']));
$to = 'email@gmail.com';
$email_subject = "Website Contact Form: $name";
$email_body = "You have received a new message from your website
contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail:
$email_address\n\nPhone: $phone\n\nMessage:\n$message";
$headers = "From: noreply@mydomain.com\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>'