My pages stopped working when the latest version of php took over a while ago. With help from you guys I managed to update it and get it working again. All was fine until I came to enable email received confirmations this week.
The code below works, however, because the parameter
"-froot@myownemailaddress.co.uk"
is hard coded in to the mail()
mail("prescriptions@myownemailaddress.co.uk", $subject, $message, $from, "-froot@myownemailaddress.co.uk");
all the emails we receive have a from address of our own email address. So when the email received confirmation goes out, WE get the confirmation it was received not the person that actually sent it using our website.
heres the full coding:
<?php
$isformvalid = true;
$isspamfree = true;
if((!$_POST['visitormail'] == "" && (!strstr($_POST['visitormail'],"@") || !strstr($_POST['visitormail'],"."))) || (empty($_POST['visitor'])) || (empty($_POST['visitormail'])) || (empty($_POST['notes'])) || (empty($_POST['dobday']) || empty($_POST['dobmonth']) || empty($_POST['dobyear'])) ) {
$isformvalid = false;
include('emailerror.php');
/* calls emailerror page insert if any field is invalid */
}
else {
include('isspam.php'); }
/* spam filters - calls spam filter check before proceeding any further */
if($isspamfree == true) {
$todayis = date("l, F j, Y, g:i a") ;
$subject = "Repeat prescription request";
$from = $_POST[visitormail];
$notes = stripcslashes($_POST['notes']);
$dob = $_POST['dobday'].$_POST['dobmonth'].$_POST['dobyear'];
/* phpinfo(INFO_VARIABLES); displays all variable values test if needed*/
$message = "$todayis [EST] \n
From: $_POST[visitor] ($_POST[visitormail])\n
DOB: $dob \n
Medication: $notes \n
Additional Info : IP = $_POST[ip] \n
Browser Info: $_POST[httpagent] \n
Referral : $_POST[httpref] \n
";
}
if(($isformvalid == true) && ($isspamfree == true)) {
"From: $_POST[from]\r\n";
mail("prescriptions@winyateshc.co.uk", $subject, $message, $from, "-froot@winyateshc.co.uk");
include('formcorrect.php');
/* calls form correct page insert */
}
?>
Previously i didnt use the "optional" header and parameter, however when the latest version of php came out a while back i had to use them otherwise the email wasnt sent.
I tried replacing the hard coded parameter of our own email address to $from so that the emails we receive correctly show as being from the sender, but when i do this the email doesnt get sent.
I checked all the variables to make sure they contain the correct entries (such as the senders email address in the $from) which they do.
They also display correctly in the CONTENT of the email we receive in $message.
Can someone please advise how i get the emails we receive to correctly show the senders email address in the from header field rather than our own addess?