soyuz02 Posted May 15, 2015 Share Posted May 15, 2015 Hi guys, Trying to customise a website template which has a contact us form and uses a php sendmail script. Problem is I'm not receiving any emails sent through it. I've run a basic php sendmail script so see whether the server allows it nd that works fine hence it must be the script Any help much appreciated! Thanks! <?php if($_REQUEST['first_name'] == '' || $_REQUEST['contact_email'] == '' || $_REQUEST['message'] == ''): return "error"; endif; if (filter_var($_REQUEST['contact_email'], FILTER_VALIDATE_EMAIL)): $subject = 'Contact from Webpage'; // Subject of your email // Receiver email address $to = 'info@test.co.uk'; //Change the email address by yours // prepare header $header = 'From: '. $_REQUEST['first_name'] . " " .$_REQUEST['last_name'] . ' <'. $_REQUEST['contact_email'] .'>'. "\r\n"; $header .= 'Reply-To: '. $_REQUEST['first_name'] . " " .$_REQUEST['last_name'] . ' <'. $_REQUEST['contact_email'] .'>'. "\r\n"; // $header .= 'Cc: ' . 'example@domain.com' . "\r\n"; // $header .= 'Bcc: ' . 'example@domain.com' . "\r\n"; $message .= 'Name: ' . $_REQUEST['first_name'] . " " .$_REQUEST['last_name'] . "\n"; $message .= 'Email: ' . $_REQUEST['contact_email'] . "\n"; $message .= 'Subject: ' . $_REQUEST['contact_subject'] . "\n"; $message .= 'Message: '. $_REQUEST['message']; // Send contact information mail($to, $subject, $message, $header); echo 'sent'; else: return "error"; endif; ?> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 17, 2015 Share Posted May 17, 2015 You state that it isn't sending the email. Is that because you don't receive one or because you get your error message? Would be nice to know. Debugging info for next post: 1 - post any code you have in the proper tags for this forum such as 'code' and '/code' in square brackets 2 - Show us the contents of the mail vars so we can see what you have built. 3 - turn on php error checking 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.