March 30, 201016 yr Hi, I'm pretty hopeless with PHP, but have managed to create a really decent contact form using a mixture of uni-form for the layout and accessibility and FormSend for the script. I've just tried to modify the script for a call back form where I literally am requesting a name, phone number and an optional message field. It all works perfectly, and the 'status' messages appear fine, but I'm not receiving the notification of the form submissions. I'm sure that it's in the $headers of the php file where I am going wrong. If anyone could point me in the right direction, that would be great. The script I am using is as follows: <? /* Silentum FormSend v1.5.0 Modified January 1, 2009 formsend.php copyright 2005-2009 "HyperSilence" */ include("options_callback.php"); $today = date("F d, Y / h:i:sa"); $subject = "Call Back Form"; $name = $HTTP_POST_VARS["name"]; $phone = $HTTP_POST_VARS["phone"]; $check = $HTTP_POST_VARS["message"]; $message = $today."\n\nName: ".strip_tags(stripslashes($HTTP_POST_VARS["name"]))."\n\nPhone: ".strip_tags(stripslashes($HTTP_POST_VARS["phone"]))."\nMessage: ".strip_tags(stripslashes($HTTP_POST_VARS["message"]))."\nIP Address: ".$_SERVER["REMOTE_ADDR"]; $headers = "From: myemailaddress@domain.com" . "\r\n" . "Reply-To: myemailaddress@domain.com" . "\r\n" . "X-Mailer: PHP/" . phpversion(); if(preg_match("/^[\.0-9a-z_-]{1,}@[\.0-9a-z-]{1,}\.[a-z]{1,}$/si", $email)) $valid = "1"; else $valid = "0"; if($name == "") { header("Location: ".$form_file."?msg=1"); exit; } elseif($phone_required == true && $subject != "" && $phone == "") { header("Location: ".$form_file."?msg=2"); exit; } elseif(strlen($message) >= $maximum_characters && $subject != "") { header("Location: ".$form_file."?msg=3"); exit; } else { mail($subject, $message, $headers); header("Location: ".$form_file."?msg=4"); } ?> I've tried many variations, such as stripping out the $headers entirely, but I'm still not receiving the notifications. Many thanks in advance for any tips. All the best Vicky
March 30, 201016 yr Hi, I'm pretty hopeless with PHP, but have managed to create a really decent contact form using a mixture of uni-form for the layout and accessibility and FormSend for the script. I've just tried to modify the script for a call back form where I literally am requesting a name, phone number and an optional message field. It all works perfectly, and the 'status' messages appear fine, but I'm not receiving the notification of the form submissions. I'm sure that it's in the $headers of the php file where I am going wrong. If anyone could point me in the right direction, that would be great. The script I am using is as follows: <? /* Silentum FormSend v1.5.0 Modified January 1, 2009 formsend.php copyright 2005-2009 "HyperSilence" */ include("options_callback.php"); $today = date("F d, Y / h:i:sa"); $subject = "Call Back Form"; $name = $HTTP_POST_VARS["name"]; $phone = $HTTP_POST_VARS["phone"]; $check = $HTTP_POST_VARS["message"]; $message = $today."\n\nName: ".strip_tags(stripslashes($HTTP_POST_VARS["name"]))."\n\nPhone: ".strip_tags(stripslashes($HTTP_POST_VARS["phone"]))."\nMessage: ".strip_tags(stripslashes($HTTP_POST_VARS["message"]))."\nIP Address: ".$_SERVER["REMOTE_ADDR"]; $headers = "From: myemailaddress@domain.com" . "\r\n" . "Reply-To: myemailaddress@domain.com" . "\r\n" . "X-Mailer: PHP/" . phpversion(); if(preg_match("/^[\.0-9a-z_-]{1,}@[\.0-9a-z-]{1,}\.[a-z]{1,}$/si", $email)) $valid = "1"; else $valid = "0"; if($name == "") { header("Location: ".$form_file."?msg=1"); exit; } elseif($phone_required == true && $subject != "" && $phone == "") { header("Location: ".$form_file."?msg=2"); exit; } elseif(strlen($message) >= $maximum_characters && $subject != "") { header("Location: ".$form_file."?msg=3"); exit; } else { mail($subject, $message, $headers); header("Location: ".$form_file."?msg=4"); } ?> I've tried many variations, such as stripping out the $headers entirely, but I'm still not receiving the notifications. Many thanks in advance for any tips. All the best Vicky In this part $headers = "From: myemailaddress@domain.com" . "\r\n" . "Reply-To: myemailaddress@domain.com" . "\r\n" . "X-Mailer: PHP/" . phpversion(); try writing the from email like this <myemailaddress@domain.com>
March 31, 201016 yr Author Hi, many thanks for the reply. I tried to implement this, but it doesn't work. I'm not sure if I have implemented it correctly. This is how I tried it: $headers = "From: <myemailaddress@domain.com>" . "\r\n" . "Reply-To: myemailaddress@domain.com" . "\r\n" . "X-Mailer: PHP/" . phpversion();
March 31, 201016 yr Just thought I'd point out that although you have this script, this code is totally outdated. The $HTTP_POST_VARS variable has been deprecated since version 4.1 - and to give you an idea of how long ago that was, well PHP stopped it's version 4 back in August 2008 roughly, so you're probably looking at a version prior to 2005 that supported this script. Since then, there have been a number of changes including vital security updates, bug fixes and so forth, so you should get your code up to a higher level asap
March 31, 201016 yr Author HI Jay Thank you for pointing that out - I'll look into it. The script was updated in January 2009, so I thought it couldn't be too out of date. Many thanks for the link. I'll amend everything accordingly.
April 1, 201016 yr Author HI Jay Thank you for pointing that out - I'll look into it. The script was updated in January 2009, so I thought it couldn't be too out of date. Many thanks for the link. I'll amend everything accordingly. Having amended the outdated code, it still isn't making any difference. The script works on the page, but it's just not sending through the message to my email address, and I'm not sure what changes I need to make. On a different page when I specify that the email address is required, it's fine, as also completes the 'From' field. Any tips would be gratefully accepted. Here's the new code: <? /* Silentum FormSend v1.5.0 Modified January 1, 2009 formsend.php copyright 2005-2009 "HyperSilence" */ include("options_callback.php"); $today = date("F d, Y / h:i:sa"); $subject = "Call Back Form"; $name = $_POST["name"]; $phone = $_POST["phone"]; $check = $_POST["message"]; $message = $today."\n\nName: ".strip_tags(stripslashes($_POST["name"]))."\n\nPhone: ".strip_tags(stripslashes($_POST["phone"]))."\nMessage: ".strip_tags(stripslashes($_POST["message"]))."\nIP Address: ".$_SERVER["REMOTE_ADDR"]; $headers = "From: vicky@mardall.co.uk" . "\r\n" . "Reply-To: vicky@mardall.co.uk" . "\r\n" . "X-Mailer: PHP/" . phpversion(); if($name == "") { header("Location: ".$form_file."?msg=1"); exit; } elseif($phone_required == true && $subject != "" && $phone == "") { header("Location: ".$form_file."?msg=2"); exit; } elseif(strlen($message) >= $maximum_characters && $subject != "") { header("Location: ".$form_file."?msg=6"); exit; } else { mail($subject, $message, $headers); header("Location: ".$form_file."?msg=7"); } ?>
April 1, 201016 yr In this line:- mail($subject, $message, $headers); where is the To ? An email needs four sections, To, Subject, Message and From but that code only has three. Try $admin="vicky@mardall.co.uk"; mail($admin, $subject, $message, $headers); if you want the email to be sent to you.
April 1, 201016 yr Author Crikey - what an easy fix - many thanks Wickham for taking the time to look through that. The options_callback.php does include an email address, but for some reason, it's obviously not recognising it.
Create an account or sign in to comment