Contact Form submits but i don't receive any emails

Ok thank you very much for all your help much appreciated

The header FROM should be a domain email address. Otherwise emails may be blocked as “email spoofing” or at the very least end up in your spam box.

$headers = 'From: '.$email_from."\r\n".

should be

$headers = 'From: info@mysite.com'."\r\n".

or a web address you’ve created for this domain.

The Reply-To: will allow you to reply the person but From: should always be a domain address.

Thank you for the response i just did the change but i do not receive any mails

Contact your host and see if they allow PHP mail().

They do because my website I had before this one was also a php and had no problems, so it means it must have been on

I’d still contact them and see if htey have any suggetions.

That doesn’t necessarily mean it allows php mail(). It may have used SMTP to send the mail or required a certain setup that you’re not following now.

There is also a typo for telephone validation.

if(!preg_match($telephone_exp,$telephone_from)) {

should be

if(!preg_match($telephone_exp,$telephone)) {

Just the fact that you are getting a php error could prevent mail() from working.
I also would suggest changing

died($error_message); 

to

die($error_message);

schwim i have some news on this matter i am having, I got the test mail you send me like 3 hours ago:

Full Name: Schwim Dandy
Telephone: 191-191-1919
Email: me@here.com
Message: It seems that your server is stopping the email from sending.

But why does it take so long to get to me?

I sent a second email to the gmail address you listed above. Did you receive that one?

Did you just now send it to me?

about 2 min ago through the mailer script on my domain.

Form details below.

Full Name: Schwim Dandy
Telephone: 818-181-8181
Email: stillme@stillhere.com
Message: This is the second test message, being sent to your gmail address directly

But how come it is working now?

Did you maybe change something in the php script?

No, I used the same script, as I told you the script works just fine as it is on my server. So far, the issues are only on your end.

I’ve modified the script to reflect the suggested changes by others above. That being the sender is going to be your info@ address, in case the server is looking for a trusted address and I’ve altered the silly phone regex string to check the actual phone variable. You can try this one and see if it works for you.

<?php // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "jstockenstroom21@gmail.com"; $email_sender = "info@momentdesigns.co.za"; $email_subject = "Your email subject line"; $stop_reason = ''; if(!ISSET($_POST['email'])) { echo("This page can only be accessed from the contact form. Sorry about that.<br />"); exit; } // validation expected data exists if((!ISSET($_POST['full_name']) OR $_POST['full_name'] == '') OR (!ISSET($_POST['telephone']) OR $_POST['telephone'] == '') OR (!ISSET($_POST['email']) OR $_POST['email'] == '') OR (!ISSET($_POST['message']) OR $_POST['full_name'] == '')) { echo("All of the form fields are required.<br />"); exit; } $full_name = $_POST['full_name']; // required $telephone = $_POST['telephone']; // required $email_from = $_POST['email']; // required $message = $_POST['message']; // required if(!filter_var($email_from, FILTER_VALIDATE_EMAIL)){ $stop = '1'; $stop_reason = $stop_reason."Email address does not appear to be valid.<br />"; } $telephone_exp = '/^[0-9]*$/'; if(!preg_match($telephone_exp,$telephone)) { $stop = '1'; $stop_reason = $stop_reason.'The Telephone number you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$full_name)) { $stop = '1'; $stop_reason = $stop_reason.'The Full Name you entered does not appear to be valid.<br />'; } if(strlen($message) < 2) { $stop = '1'; $stop_reason = $stop_reason.'The Message you entered do not appear to be valid.<br />'; } if(ISSET($stop)){ echo(" Your message was unable to be sent because of the following:<br /> <br /> ".$stop_reason." <br /> Please feel free to try again. "); UNSET($stop); exit; } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($full_name)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Message: ".clean_string($message)."\n"; // create email headers $headers = 'From: '.$email_sender."\r\n". 'Reply-To: '.$email_sender."\r\n" . 'X-Mailer: PHP/' . phpversion(); if(mail($email_to,$email_subject,$email_message,$headers)) { echo '<script type="text/javascript">alert("Thank you, your request has been submitted!");</script>'; echo "<meta http-equiv='refresh' content='0;url=http://www.momentdesigns.co.za/'>"; }else{ echo "There was a problem sending the mail. We're really sorry about that."; } ?>

Ok so I have to phone my Service provider and tell them everything is working so it has to be something on there side?

I just send myself an email on my gmail account and nothing is happening. I am using cpanel can there be something on there or is it my service provider?

You have to contact the host of the server that the script resides on. If that is the momentsdesign domain, then it looks like you want to contact MWEB: http://www.mweb.co.za/

When I googled MWEB php mail, I found that others have complained that they were unable to use php’s mail function: https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=mweb%20allow%20php%20mail