Hello Everyone,
I'm a relatively new web designer and I've been tearing my hair out for the past month, going between my VPS support team and my client's ISP tech support. Here's the issue:
I'm hosting a website with a PHP contact form. When the user submits the form, contactengine.php is run, and the information should get sent directly to my client's email. Unfortunately, some time in December, my client stopped receiving the messages (it had been working fine for 8 months!) I updated the script, and added my email address to the "To" field so that I could ensure the script was still working properly. I receive the form messages 100% of the time. My client receives messages about 5% of the time. Both support teams claim the issue is with the other service, and I'm stuck in the middle with a PHP form that works for me.
So, now, I'm turning to the forums to see if anyone knows of what to possibly try next! Below is the code that I have in my PHP script. Any help would be GREATLY appreciated!
Some notes about the code:
- "client@example.com" is my client's main email address
- "from@example.com" is a new email address created, hosted on the local server, but isn't used than being the "from" address
- "me@example.com" is my email, so that when a message is received from online, I can at least forward those to my client. It's a pain, but it's working.
<?php
$EmailTo = "client@example.com, me@example.com";
$Subject = "Tanoak Boxers - Website Contact Form";
$Name = Trim(stripslashes($_POST['Name']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Email = Trim(stripslashes($_POST['Email']));
$Message = Trim(stripslashes($_POST['Message']));
$Headers = 'From: from@example.com' . "\r\n" .
'Reply-To: ' . $Email;
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
exit;
}
function formatPhone($num)
{
$num = ereg_replace('[^0-9]', '', $num);
$len = strlen($num);
if($len == 7)
$num = preg_replace('/([0-9]{3})([0-9]{4})/', '$1-$2', $num);
elseif($len == 10)
$num = preg_replace('/([0-9]{3})([0-9]{3})([0-9]{4})/', '($1) $2-$3', $num);
return $num;
}
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= formatPhone($Phone);
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, $Headers);
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>
Thanks in advance,
Mindy : )