donnierisk Posted March 24, 2013 Share Posted March 24, 2013 Hi everyone, I've created a website with a simple form that when filled in sends the information in a form of an email to the specified email address. For some reason I don't seem to be receiving emails anymore at all whereas i used to be able to get them, i've tested it myself by entering dummy info and submiting, yet I still don't get anything. All problem I can think of is that I accidentally changed the code in the past month or two, but I can't seem to find what's wrong. Please someone help, the code for the form and the php is here: form: <form id="theForm" name="theForm" method="post" onsubmit="return formValidating();" action="sendTo.php"> <p> Full name: </p> <input type="text" name="theName" id="theName" placeholder="Your name"/> <p> Email address: </p> <input type="email" name="emailAddress" id="emailAddress" placeholder="Eg, me@thePlace.net" /> <p> Contact number: </p> <input type="text" name="theNumber" id="theNumber" placeholder="tel"/> <p> Area: </p> <input type="text" name="theArea" id="theArea" placeholder="Your area"/> <p> Description (photoshoot details): </p> <textarea name="theDescription" id="theDescription" placeholder="tel" rows="10" cols="30"> </textarea> <br/> <br/> <input type="submit" value="Send" id="submitButton" /> </form> PHP "sendTo.php" <?php $name = $_POST['theName']; $visitor_email = $_POST['emailAddress']; $number = $_POST['theNumber']; $area = $_POST['theArea']; $description = $_POST['theDescription']; $email_from = 'info@luketannous.com'; $email_subject = "LT Photography New Form submission"; $email_body = "You have received a new message from the user: ".$name."\n \n His email address: ".$visitor_email ."\n His contact details: ". $number ."\n His area: ". $area ."\n Photoshoot Description : ". $description ." \n". $to = "donnierisk@gmail.com"; $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; $success = mail($to,$email_subject,$email_body,$headers); if($success){ echo "<div style='height:200px'> </div><p style='text-align:center;margin:auto;'>Your e-mail has been sent succesfully.</p> "; echo "<p style='text-align:center;margin:auto;'> <br/>Automatically redirecting you back to the home page...</p> "; header( "refresh:5;url=index.html" ); } else{ echo "<div style='height:200px'> </div><p style='text-align:center;margin:auto;'>Your email failed to send, please try again or contact me via telephone</p> "; echo "<p style='text-align:center;margin:auto;'>Click <a href='contact.html'> here </a> to go back to the contact page</p> "; } ?> Note that I have omitted irrelevant code (html tags, etc). The submit button works, because the page comes up with the if($success) part, you can check here to see for yourself: http://www.luketannous.co.za/contact.html Hope someone can help me with this simple and embarrassing problem. Quote Link to comment https://forums.phpfreaks.com/topic/276102-php-form-not-submitting-to-email/ Share on other sites More sharing options...
davidannis Posted March 24, 2013 Share Posted March 24, 2013 Last time that happened to me it turned out that the servers IP address had ended up an a blackhole list. Have you checked to make sure outgoing mail from that server not generated in php reaches you? Quote Link to comment https://forums.phpfreaks.com/topic/276102-php-form-not-submitting-to-email/#findComment-1420803 Share on other sites More sharing options...
donnierisk Posted March 24, 2013 Author Share Posted March 24, 2013 I double checked by going to some websites that do a check, it isn't blocked anywhere, I think that's what you mean? I went to www.mob.net and a few others and entered my website's URL there. Otherwise I don't know how to check, I logged into the website's personal email and sent/received a few things, it works fine. Is it possible that my web host could be affecting this in any way? Quote Link to comment https://forums.phpfreaks.com/topic/276102-php-form-not-submitting-to-email/#findComment-1420806 Share on other sites More sharing options...
haku Posted March 25, 2013 Share Posted March 25, 2013 If the mail() function is successful, it means that PHP has been able to pass the mail off to the mail server. This means that the problem isn't in your script, but rather in your server configuration. Does the 'from' address actually exist? If it doesn't, some hosts will block you from sending from that address (as you could be spamming from a non-existent address). Talk to your hosting company to see if they can help you debug the issue. Quote Link to comment https://forums.phpfreaks.com/topic/276102-php-form-not-submitting-to-email/#findComment-1420826 Share on other sites More sharing options...
donnierisk Posted March 25, 2013 Author Share Posted March 25, 2013 Oh okay that makes sense, I appreciate the help! Will try to contact them and see what can be done, i'm just glad it's not the code. Quote Link to comment https://forums.phpfreaks.com/topic/276102-php-form-not-submitting-to-email/#findComment-1420898 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.