shane_77 Posted July 21, 2014 Share Posted July 21, 2014 Im having a problem with my form mail on my websites. Now the problem I have only happens with sites that I upload to my hosting accounts with Host gator. The mail will only deliver to the domain email address it wont deliver to gmail or yahoo or any other email address. I tested the script on an old domain with an Irish hosting account and it works perfectly it delivers to gmail and yahoo and my domain email account. Ive been pulling my hair out talking to Hostgator staff all weekend they keep blaming gmail and yahoo and insist the problem is not on there end. Anyway I was wondering is there anything I can add to my PHP script to make sure it delivers to gmail and yahoo or is there anything wrong with my script as hostgator are saying. Maybe there is a security issue or something Im very new to php so i could be missing something simple. Thanks for the Help <?php/* Set e-mail recipient */$myemail = "info@shaneswebdesign.com"; /* Check all form inputs using check_input function */$yourname = check_input($_POST['yourname'], "Enter your name");$subject = check_input($_POST['subject'], "Write a subject");$email = check_input($_POST['email']);$website = check_input($_POST['website']);$likeit = check_input($_POST['likeit']);$how_find = check_input($_POST['how']);$comments = check_input($_POST['comments'], "Write your comments"); /* If e-mail is not valid show error message */if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)){ show_error("E-mail address not valid");} /* If URL is not valid set $website to empty */if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website)){ $website = '';} /* Let's prepare the message for the e-mail */$message = "Hello! Your contact form has been submitted by: Name: $yournameE-mail: $emailURL: $website Area of Interest? $how_find Comments:$comments End of message"; /* Send the message using mail() function */mail($myemail, $subject, $message); /* Redirect visitor to the thank you page */header('Location: http://www.shaneswebdesign.com/thanks.php');exit(); /* 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><?phpexit();}?> Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 21, 2014 Share Posted July 21, 2014 It's not your host that is the problem. One big problem is that you are missing the basic important headers for the mail function. Here is a article I wrote on this subject http://amecms.com/article/Sending-email-in-PHP-and-reaching-the-inbox Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.