jofield
11-20-2011, 10:39 AM
I have a form currently working for a client on their website but when information is submitted through it the email that arrives displays the form contents as an .htm file attached to the email rather than just text within the email body. The client hosts with fasthost if this makes a difference as I have done some research on Goggle and found that they do have quite specific requirments. The form is working so I believe I have filled these requirements but can't work out why the responses are coming through as attachments. Does anyone have any idea why and how i can change this please?
Any suggestions will be greatly appreciated!
Thanks
<?php
session_start();
include('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 = '[removed for security]';
$email_from = $_POST["email"];
$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"]."\r\n";
$MESSAGE_BODY .= "Job Title: ".$_POST["job_title"]."\r\n";
$MESSAGE_BODY .= "Company: ".$_POST["company"]."\r\n";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."\r\n";
$MESSAGE_BODY .= "Address: ".nl2br($_POST["address"])."\r\n";
$MESSAGE_BODY .= "Telephone: ".$_POST["phone"]."\r\n";
$MESSAGE_BODY .= "Course Title: ".$_POST["course_title"]."\r\n";
$MESSAGE_BODY .= "Course Date: ".$_POST["course_date"]."\r\n";
// This is the important ini_set command which sets the sendmail_from address, without this the email won't send.
ini_set("sendmail_from", $email_from);
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
header('Location: '.$_POST['referrer'].'?success=1'); // Redirect on success
} else {
echo('Your email address was left blank. Please click back and type your email address.');
exit();
}
?>
Any suggestions will be greatly appreciated!
Thanks
<?php
session_start();
include('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 = '[removed for security]';
$email_from = $_POST["email"];
$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"]."\r\n";
$MESSAGE_BODY .= "Job Title: ".$_POST["job_title"]."\r\n";
$MESSAGE_BODY .= "Company: ".$_POST["company"]."\r\n";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."\r\n";
$MESSAGE_BODY .= "Address: ".nl2br($_POST["address"])."\r\n";
$MESSAGE_BODY .= "Telephone: ".$_POST["phone"]."\r\n";
$MESSAGE_BODY .= "Course Title: ".$_POST["course_title"]."\r\n";
$MESSAGE_BODY .= "Course Date: ".$_POST["course_date"]."\r\n";
// This is the important ini_set command which sets the sendmail_from address, without this the email won't send.
ini_set("sendmail_from", $email_from);
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
header('Location: '.$_POST['referrer'].'?success=1'); // Redirect on success
} else {
echo('Your email address was left blank. Please click back and type your email address.');
exit();
}
?>