munchkinz Posted January 23, 2011 Share Posted January 23, 2011 Hi, I had a website running a few months ago with a working contact form I am now building a new website and have copied the files changing relevant info but it is not not working it is sending me to the thank you page but the email is not coming through. Can anybody see why? <?php $EmailTo = "[email protected]"; $Subject = "Contact from Website"; $Title = Trim(stripslashes($_POST['Title'])); $FName = Trim(stripslashes($_POST['First Name'])); $LName = Trim(stripslashes($_POST['Last Name'])); $Email = Trim(stripslashes($_POST['Email'])); // prepare email body text $Body = ""; $Body .= "Title: "; $Body .= $Title; $Body .= "\n"; $Body .= "First Name: "; $Body .= $FName; $Body .= "\n"; $Body .= "Last Name: "; $Body .= $LName; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$Email>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">"; } ?> <form action="quoteform.php" method="post" enctype="multipart/form-data" name="quoteform" id="quoteform"> <label for="Title" id="Title">Title:</label><select name="Title"> <option value="Mr">Mr</option> <option value="Mrs">Mrs</option> <option value="Miss">Miss</option> <option value="Ms">Ms</option> <option value="Dr">Dr</option> <option value="Other">Other</option> </select> <label for="FName" id="FName">First Name:</label><input name="First Name" type="text" size="25"> <label for="LName" id="LName">Last Name:</label><input name="Last Name" type="text" size="25"> <label for="Email" id="Email">Email:</label><input name="Email" type="text" size="50"> <input type="submit" name="submit" value="Send" class="submit-button" title="Submit" /> <input type="button" value="Clear Message" onClick="document.forms['quoteform'].Message.value=''" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/225435-php-form-not-sending-email/ Share on other sites More sharing options...
mike12255 Posted January 23, 2011 Share Posted January 23, 2011 have you tried echoing out all your variables to make sure your getting what you want from them? Quote Link to comment https://forums.phpfreaks.com/topic/225435-php-form-not-sending-email/#findComment-1164129 Share on other sites More sharing options...
Simon Mayer Posted January 23, 2011 Share Posted January 23, 2011 Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination. There is something a little bit odd about your From header. If you are just including the email address, it's not normal to use <> I'm not sure if it's non-standard, but I would expect to either see: $success = mail($EmailTo, $Subject, $Body, "From: $Email"); or $success = mail($EmailTo, $Subject, $Body, "From: $FName $LName <$Email>"); Generally, I'm also against putting variables inside quotes. It's better to do this, so you can work out what is going on more easily: "From: " . $FName . " " . $LName . " <" . $Email . ">" I see spaces in the name value for First Name and Last Name. You should avoid spaces. Use an underscore instead. Just out of interest, the following is a better way of redirecting // redirect to success page if ($success){ header('Location: thankyou.php'); } else{ header('Location: error.php'); } Quote Link to comment https://forums.phpfreaks.com/topic/225435-php-form-not-sending-email/#findComment-1164145 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.