jofield
11-12-2011, 05:10 PM
Hi
I have a form I have set up using php that should submit an email on completion. When I set it up and tested it on my own website it worked absolutely fine but now I have uploaded it to a different website it no longer sends the email even though I get no error messages. i have spoken to the hosting company who have advised Emails have to have a senders address specified in your code, the server will reject any other emails to prevent spam. But surely that's what this line of my code does:
$mailheader = "From: ".$_POST["email"]."\r\n";
doesn't it?
Can anyone help me please?
Full code supplied below
Thanks
<?php
session_start();
include('http://www.rework.co.uk/forms/securimage/securimage.php');
$securimage = new Securimage();
if($securimage->check($_POST['captcha_code']) == false) {
// The code was incorrect
echo "The security code entered was incorrect.<br /><br />";
echo "Please click back and try again.";
exit();
}
if($_POST["email"] != '') {
$ToEmail = '[myemailaddress]';
$EmailSubject = 'Online Course Enquiry';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Job Title: ".$_POST["job_title"]."<br>";
$MESSAGE_BODY .= "Company: ".$_POST["company"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Address: ".nl2br($_POST["address"])."<br>";
$MESSAGE_BODY .= "Telephone: ".$_POST["phone"]."<br>";
$MESSAGE_BODY .= "Course Title: ".$_POST["course_title"]."<br>";
$MESSAGE_BODY .= "Course Date: ".$_POST["course_date"]."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
header('Location:http://www.rework.co.uk/trainingsche...ccess=1'); // Redirect on success
} else {
echo('Your email address was left blank. Please click back and type your email address.');
exit();
}
?>
I have a form I have set up using php that should submit an email on completion. When I set it up and tested it on my own website it worked absolutely fine but now I have uploaded it to a different website it no longer sends the email even though I get no error messages. i have spoken to the hosting company who have advised Emails have to have a senders address specified in your code, the server will reject any other emails to prevent spam. But surely that's what this line of my code does:
$mailheader = "From: ".$_POST["email"]."\r\n";
doesn't it?
Can anyone help me please?
Full code supplied below
Thanks
<?php
session_start();
include('http://www.rework.co.uk/forms/securimage/securimage.php');
$securimage = new Securimage();
if($securimage->check($_POST['captcha_code']) == false) {
// The code was incorrect
echo "The security code entered was incorrect.<br /><br />";
echo "Please click back and try again.";
exit();
}
if($_POST["email"] != '') {
$ToEmail = '[myemailaddress]';
$EmailSubject = 'Online Course Enquiry';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Job Title: ".$_POST["job_title"]."<br>";
$MESSAGE_BODY .= "Company: ".$_POST["company"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Address: ".nl2br($_POST["address"])."<br>";
$MESSAGE_BODY .= "Telephone: ".$_POST["phone"]."<br>";
$MESSAGE_BODY .= "Course Title: ".$_POST["course_title"]."<br>";
$MESSAGE_BODY .= "Course Date: ".$_POST["course_date"]."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
header('Location:http://www.rework.co.uk/trainingsche...ccess=1'); // Redirect on success
} else {
echo('Your email address was left blank. Please click back and type your email address.');
exit();
}
?>