3ddream Posted April 22, 2010 Share Posted April 22, 2010 hello there , I am trying to solve this problem i dont know why this happening I have attached my form - this form works fine but only on that email my email [email protected] if i change it to a yahoo or gmail i never get an email back ? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2010 Share Posted April 22, 2010 You are not putting the $headers variable into the mail() function call, so your email either has no From: address or it is using the default From: address that is set in the php.ini. This limits who your sending mail server will send to and which receiving mail servers will accept the email. Once you correct the code so that $headers is used in the mail() function call, it should work better. Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046346 Share on other sites More sharing options...
3ddream Posted April 22, 2010 Author Share Posted April 22, 2010 Once you correct the code so that $headers is used in the mail() function call, it should work better. how can i correct this ? Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046347 Share on other sites More sharing options...
Sergey Popov Posted April 22, 2010 Share Posted April 22, 2010 Big chances that you can find your messages in the SPAM folder in your Gmail/Yahoo account. If putting headers (as suggested by PFMaBiSmAd) not help - it is likely that your server's IP is blacklisted, and you'll need to investigate and resolve this with your hosting provider. As for headers, here is how to do this: $headers ="MIME-Version: 1.0\n"; $headers.="Content-type: text/html; charset=utf-8\n"; $headers.="Content-transfer-encoding: 8Bit\n"; $headers.="Return-Path: <[email protected]>\n"; $headers.="Message-ID: <".time()."[email protected]>\n"; $headers.="From: [email protected]\n"; $headers.="Reply-To: [email protected]\n"; if(!mail($to,$subject,$message,$headers)){ return false; } else{ return true; } Replace [email protected] to your email address. Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046348 Share on other sites More sharing options...
3ddream Posted April 22, 2010 Author Share Posted April 22, 2010 hI Sergey i checked that but its not on the spam Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046350 Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2010 Share Posted April 22, 2010 how can i correct this ? The documentation shows where $header would be used in the mail statement - http://us3.php.net/manual/en/function.mail.php Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046364 Share on other sites More sharing options...
3ddream Posted April 22, 2010 Author Share Posted April 22, 2010 I am not very familiar with this, lets say that i want to send the form to [email protected] what i need to do with the header? can u help Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046367 Share on other sites More sharing options...
3ddream Posted April 22, 2010 Author Share Posted April 22, 2010 still i cannot make it work what do i need to correct here <?php if(isset($_POST['submit'])) { $response = "Thank you!"; $_POST['response'] = $response; $to = "[email protected]"; $subject = "Form"; $name = $_POST['name']; $email = $_POST['email']; $company = $_POST['company']; $message = $_POST['message']; $headers = "From: 3DDream.Net | Contact Form<[email protected]> \n"; $headers .= "Reply-To: {$email}"; $error = false; if(strlen($name) == 0) $error = "Empty name"; if(strlen($email) == 0) $error = "Empty email"; if(strlen($company) == 0) $error = "Empty company"; if(strlen($message) == 0) $error = "Empty message"; $body = "From: $name\n Email: $email\n Company: $company\n Message: $message\n"; if(!$error) mail($to, $subject, $body); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046371 Share on other sites More sharing options...
Sergey Popov Posted April 22, 2010 Share Posted April 22, 2010 See above in my edited post, or mail() function syntax. You have: mail($to, $subject, $body); Must be: mail($to, $subject, $body,$header); Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046378 Share on other sites More sharing options...
3ddream Posted April 22, 2010 Author Share Posted April 22, 2010 thanks sergey i try that no luck ????? i tried mail($to, $subject, $body, $headers); and mail($to, $subject, $body, $header); <?php if(isset($_POST['submit'])) { $response = "Thank you!"; $_POST['response'] = $response; $to = "[email protected]"; $subject = "UK Scrap Cars Form"; $name = $_POST['name']; $email = $_POST['email']; $company = $_POST['company']; $message = $_POST['message']; $headers = "From: 3DDream.Net | Contact Form<[email protected]> \n"; $headers .= "Reply-To: {$email}"; $error = false; if(strlen($name) == 0) $error = "Empty name"; if(strlen($email) == 0) $error = "Empty email"; if(strlen($company) == 0) $error = "Empty company"; if(strlen($message) == 0) $error = "Empty message"; $body = "From: $name\n Email: $email\n Company: $company\n Message: $message\n"; if(!$error) mail($to, $subject, $body, $headers); } ?> i have attach the form [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046388 Share on other sites More sharing options...
3ddream Posted April 22, 2010 Author Share Posted April 22, 2010 still i cannot make it work.. any help please? Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046427 Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2010 Share Posted April 22, 2010 Check if there are any php errors reported. Add the following two lines of code immediately after the first opening <?php tag - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046435 Share on other sites More sharing options...
3ddream Posted April 22, 2010 Author Share Posted April 22, 2010 the only error i am getting is for the responce command Notice: Undefined variable: response in /contact.php on line 139 but still the form doesnt work can someone help me please ? have tried so many times Quote Link to comment https://forums.phpfreaks.com/topic/199364-php-contact-form-help/#findComment-1046443 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.