I am now able to receive email except for emails sent from my site's info form via PHP script. It's a simple PHP form/mail script that I've never had issues with before so I don't understand why it's not working.
This is the script (abbreviated version substituting myemail@mydomain.com for my real email address) I'm trying to run:
Why is it not working? Thanks.
This is the script (abbreviated version substituting myemail@mydomain.com for my real email address) I'm trying to run:
PHP:
<?php
// VALUES FROM THE FORM
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$purpose = $_POST['purpose'];
$textarea = $_POST['textarea'];
// ERROR & SECURITY CHECKS
if ( ( !$email ) ||
( strlen($_POST['email']) > 200 ) ||
( !preg_match("#^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$#", $email) )
)
{
print "Error: Invalid E-Mail Address";
exit;
}
if ( ( !$name ) ||
( strlen($name) > 100 ) ||
( preg_match("/[:=@\<\>]/", $name) )
)
{
print "Error: Invalid Name";
exit;
}
if ( preg_match("#cc:#i", $message, $matches) )
{
print "Error: Found Invalid Header Field";
exit;
}
if (eregi("\r",$email) || eregi("\n",$email)){
print "Error: Invalid E-Mail Address";
exit;
}
if (FALSE) {
print "Error: You cannot send to an email address on the same domain.";
exit;
}
// CREATE THE EMAIL
$headers = "Content-Type: text/plain; charset=iso-8859-1\n";
$headers .= "From: $name <$email>\n";
$recipient = "myemail@mydomain.com";
$subject = "Request from $email";
$message = "Submitted by:
Name: $name
E-mail: $email
Phone: $phone
I would like to: $purpose
Details/Special Instructions: $textarea
End of message
";
// SEND THE EMAIL TO YOU
mail($recipient, $subject, $message, $headers);
// REDIRECT TO THE THANKS PAGE
header("location: thankyou.html");
/* Functions we used */
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
Why is it not working? Thanks.