danp2010 Posted August 4, 2010 Share Posted August 4, 2010 Hi Guys, I have a small issue with a new php script I wrote. It works fine, except for one issue. When the scrip emails me the info it captures, I need it to have the email sent to me from the person filling out the form. i.e. from the email address located in the $email field. It does not. Here's the code. (domain.com is just a dummy name to hold the spot, obviously.) <?php /* Subject and email */ $emailSubject = 'Centre Street Registration'; $webMaster = '[email protected]'; /* Gathering Data */ $firstname = $_POST['FirstName']; $lastname = $_POST['LastName']; $email = $_POST['Email']; $daytime = $_POST['Daytime']; $home = $_POST['Home']; $citytown = $_POST['CityTown']; $movingwhen = $_POST['MovingWhen']; $hearofus = $_POST['HearofUs']; $contactmethod = $_POST['ContactMethod']; $squareft = $_POST['SqareFt']; $important = $_POST['Important']; $pricerange = $_POST['PriceRange']; $body = <<<EOD First Name: $firstname Last Name: $lastname Email: $email Daytime Number: $daytime Home Number: $home City: $citytown Moving When: $movingwhen Hear of Us: $hearofus Contact Method: $contactmethod Square Feet: $squareft Important to You: $important Price Range: $pricerange Excel Data: $firstname,$lastname,$email,$daytime,$home,$citytown,$movingwhen,$hearofus,$contactmethod,$squareft,$important,$pricerange EOD; $headers = "From: $email"; $headers .= "Conten-type: text/html"; $success = mail($webMaster, $emailSubject, $body); /* Results rendered as HTML */ /* $theResults = 'domain.com'; */ header( "Location: http://www.dommain.com/thankyou_centre.shtml" ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/209796-small-php-email-issue/ Share on other sites More sharing options...
TOA Posted August 4, 2010 Share Posted August 4, 2010 Check the name of the email field in the form, make sure it matches (caps and all). Are the rest of the variables being populated? Also, you're not including the $headers variable in the mail() function, not sure if you noticed Quote Link to comment https://forums.phpfreaks.com/topic/209796-small-php-email-issue/#findComment-1095143 Share on other sites More sharing options...
PFMaBiSmAd Posted August 4, 2010 Share Posted August 4, 2010 I need it to have the email sent to me from the person filling out the form. No, you don't. It is your mail server that is sending the email to you. The From: address must be a valid mail box at the sending mail server. You would want to put the visitor's entered email address into the Reply-to: address in the header. Quote Link to comment https://forums.phpfreaks.com/topic/209796-small-php-email-issue/#findComment-1095144 Share on other sites More sharing options...
danp2010 Posted August 4, 2010 Author Share Posted August 4, 2010 Fixed. Adding the $headers variable did the trick. Thanks, I'm new to php but this site is a great resource. Quote Link to comment https://forums.phpfreaks.com/topic/209796-small-php-email-issue/#findComment-1095146 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.