Jump to content

PHP form not submitting to email


donnierisk

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.