Jump to content

mail() problems


KevinM1

Recommended Posts

I have the following quick and dirty contact form script:

 

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

if (isset($_POST['submit']))
{
	if (isset($_POST['name']) && !empty($_POST['name']))
	{
		if (preg_match("/^[A-Z\-' ]+$/i", $_POST['name']))
		{
			$name = $_POST['name'];
		}
		else { $name = false; }
	}
	else { $name = false; }

	if (isset($_POST['email']) && !empty($_POST['email']))
	{
		if (preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i", $_POST['email']))
		{
			$email = $_POST['email'];
		}
		else { $email = false; }
	}
	else { $email = false; }

	$message = htmlentities(trim($_POST['message']), ENT_QUOTES, "utf-8");
	$message = "Email Address of user: $email<br /><br />Message:<br />$message";

	$headers = 'From: [email protected]' . "\r\n" .
					'Reply-To: [email protected]' . "\r\n";

	if ($name && $email)
	{
		if (mail("*******", "Major Productions Inquery From $email", $message, $headers))
		{
			header("Location: success.html");
			exit;
		}
		else
		{ 
			header("Location: failure.html");
			exit;
		}
	}
	else
	{
		header("Location: failure.html");
		exit;
	}
}
else
{
	header("Location: home.html");
	exit;
}
?>

 

For some reason, mail is failing.  Error reporting shows nothing when I remove the header redirects.  Anything jump out as being wrong?  The headers, perhaps?  I'm thinking it's something with the shared hosting I'm on, but want to verify I didn't do something dumb before submitting a ticket to them.

Link to comment
https://forums.phpfreaks.com/topic/205998-mail-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.