nevell Posted January 24, 2011 Share Posted January 24, 2011 Can somebody tell me how to make this exact code send mail? I tested it on my website and it doesn't send any emails. The first code is the file contact_config.php <?php $mailto = "youremail@email.com"; $charset = "windows-1251"; $subject = "Site visitor: ".$_POST['posName']; $content = "text/html"; $message = "Site visitor information: <br><br> Name: ".$_POST['posName'] ."<br>E-mail: ".$_POST['posEmail'] ."<br>Country: ".$_POST['posCountry'] ."<br>Phone: ".$_POST['posRegard'] ."<br>Comments: ".$_POST['posText']; $statusError = ""; $statusSuccess = ""; $errors_name = 'Please enter the Name'; $errors_mailfrom = 'Please enter the Email'; $errors_incorrect = 'The e-mail address you entered does not eppear to be valid. <br>Your e-mail address should look like yourname@domain.com'; $errors_message = 'Please enter the Message'; $errors_subject = 'Please enter the Phone'; $captcha_error = 'Wrong security code!'; $send = 'Thank you for your message'; ?> <?php $mailto = "youremail@email.com"; $charset = "windows-1251"; $subject = "Site visitor: ".$_POST['posName']; $content = "text/html"; $message = "Site visitor information: <br><br> First Name: ".$_POST['posName'] ."<br>Last Name: ".$_POST['posName2'] ."<br>E-mail: ".$_POST['posEmail'] ."<br>Telephone: ".$_POST['posRegard'] ."<br>City where jobsite is located: ".$_POST['posText'] ."<br>want us to e-mail you the free Homeowners Guide To Remodeling: ".$_POST['posBox']; $statusError = ""; $statusSuccess = ""; $errors_name = 'Please enter the First Name'; $errors_name2 = 'Please enter the Last Name'; $errors_telephone = 'Please enter the Telephone'; $errors_city = 'Please enter the City where jobsite is located'; $errors_mailfrom = 'Please enter the Email'; $errors_incorrect = 'The e-mail address you entered does not eppear to be valid. <br>Your e-mail address should look like yourname@domain.com'; $captcha_error = 'Wrong security code!'; $send = 'Thank you for your message'; ?> The second code is contacts.php <?php include('kcaptcha/kcaptcha.php'); session_start(); require_once("contact_config.php"); if ($_POST['act']== "y") { if(isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] == $_POST['keystring']) { if (isset($_POST['posName']) && $_POST['posName'] == "") { $statusError = "$errors_name"; } elseif (isset($_POST['posEmail']) && $_POST['posEmail'] == "") { $statusError = "$errors_mailfrom"; } elseif(isset($_POST['posEmail']) && !preg_match("/^([a-z,._,0-9])+@([a-z,._,0-9])+(.([a-z])+)+$/", $_POST['posEmail'])) { $statusError = "$errors_incorrect"; unset($_POST['posEmail']); } elseif (isset($_POST['posText']) && $_POST['posText'] == "") { $statusError = "$errors_message"; } elseif (!empty($_POST)) { $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: $content charset=$charset\r\n"; $headers .= "Date: ".date("Y-m-d (H:i:s)",time())."\r\n"; $headers .= "From: \"".$_POST['posName']; $headers .= "X-Mailer: My Send E-mail\r\n"; mail("$mailto","$subject","$message","$headers"); $_POST['posRegard'] = ""; $_POST['posText'] = ""; $_POST['posCountry'] = ""; $_POST['posEmail'] = ""; $_POST['posName'] = ""; unset($name, $posText, $mailto, $subject, $posRegard, $message); $statusSuccess = "$send"; } }else{ $statusError = "$captcha_error"; unset($_SESSION['captcha_keystring']); } } $cat_name="Contact $store_name manager"; ?> Now for some reason the two of these files are supposed to send me emails when customers click the submit email button on my form but, I don't get any emails. I tested it myself and no emails. Help please! Quote Link to comment Share on other sites More sharing options...
gristoi Posted January 24, 2011 Share Posted January 24, 2011 Hi nevell, One thing straight away that is going to cause you an issue are your header declarations in your contacts.php. if you echo out your headers you have an extra " escaping the string. Change: $headers .= "From: \"".$_POST['posName']; to: $headers .= "From: ".$_POST['posName']; and $send = mail("$mailto","$subject","$message","$headers"); to: $send = mail($mailto,$subject,$message,$headers); hope this points you in the right direction Quote Link to comment Share on other sites More sharing options...
nevell Posted January 24, 2011 Author Share Posted January 24, 2011 That fixed the send part. I now receive the emails but now they look like spam Site visitor information: First Name: nevell Last Name: E-mail: test@gmail.com Telephone: 1234567890 City where jobsite is located: test email want us to e-mail you the free Homeowners Guide To Remodeling: <----that looks like spam wtf ? Quote Link to comment Share on other sites More sharing options...
gristoi Posted January 24, 2011 Share Posted January 24, 2011 Hi, I'm afraid I only had a quick glance at this before. What is it that you are trying to achieve in the email? Have you got an example of what you want the email to look like? Quote Link to comment Share on other sites More sharing options...
nevell Posted January 24, 2011 Author Share Posted January 24, 2011 actually I found it. But I want my form and email to show City, State, zip, and comments here is what it currently looks like http://emergencypcrepairs.net/contacts.php I want to replace that country part with city, state zip Quote Link to comment Share on other sites More sharing options...
gristoi Posted January 24, 2011 Share Posted January 24, 2011 Ok, So your going to want to change the section of the form from: <tr> <td><label for="posCountry">Country:</label></td><td><input class="input_contact" type="text" size="25" name="posCountry" id="posCountry" value=""/> </td> </tr> to: <tr> <td><label for="posCity">City:</label></td><td><input class="input_contact" type="text" size="25" name="posCity" id="posCity" value=""/> </td> </tr> <tr> <td><label for="posState">State:</label></td><td><input class="input_contact" type="text" size="25" name="posState" id="posState" value=""/> </td> </tr> <tr> <td><label for="posZip">Zip Code:</label></td><td><input class="input_contact" type="text" size="25" name="posZip" id="posZip" value=""/> </td> </tr> and in your config_contacts.php change: ."<br>Country: ".$_POST['posCountry'] to: ."<br>City: ".$_POST['posCity'] ."<br>State: ".$_POST['posState'] etc ......................... hope that helps Quote Link to comment Share on other sites More sharing options...
nevell Posted January 24, 2011 Author Share Posted January 24, 2011 Thats the form part now 1 more bother and I'll leave you be. I want the form information sent to me in a email currently the email only sends me this info: Site visitor information: First Name: nevell Last Name: E-mail: nevellholmes@gmail.com Telephone: 1234567890 City where jobsite is located: test email The email doesn't even send me the comment part. It shows the comments in the "city where jobsite is located" Thanks a lot I really appreciate all your help. Quote Link to comment Share on other sites More sharing options...
gristoi Posted January 24, 2011 Share Posted January 24, 2011 by the look of it that is just a typo in the contact_config.php, the 'City where jobsite is located' part is actually pulling the comments: ."<br>City where jobsite is located: ".$_POST['posText'] should be: ."<br>Comments: ".$_POST['posText'] . To save going over old code i think what you want is this: $message = "Site visitor information: <br><br> Name: ".$_POST['posName'] ."<br>E-mail: ".$_POST['posEmail'] ."<br>Phone: ".$_POST['posRegard'] ."<br>Location Details: <br>City: ".$_POST['posCity'] ."<br>State: ".$_POST['posState'] ."<br>Zip Code: ".$_POST['posZip'] ."<br>User Comments: ".$_POST['posText']; that should get you on your way Quote Link to comment Share on other sites More sharing options...
nevell Posted January 24, 2011 Author Share Posted January 24, 2011 Ah thanks so much my main man. This is now my outcome Site visitor information: Name: nevell E-mail: test@gmail.com Phone: 1234567890 Location Details: City: nyc State: ny Zip Code: 10453 User Comments: well this is a text Quote Link to comment Share on other sites More sharing options...
gristoi Posted January 24, 2011 Share Posted January 24, 2011 Glad I could help Quote Link to comment 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.