...

View Full Version : Unusual email received from form submission



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();
}
?>

Adee
11-20-2011, 10:43 AM
Try removing the content-type: text/html line

jofield
11-20-2011, 11:04 AM
Thanks Adee, that worked a treat!!!
Yet another mistake to prove what a rookie I am ;)

jofield
11-20-2011, 01:39 PM
I am experiencing a different issue now though, one of the forms I have amended also has some checkboxes that were working fine but now only one option displays in the submission email regardless of how many emails are ticked, would anyone know why this is please?



<?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 use your browser's Back button to fix.";
exit();
}

$contact_options_msg = $_POST['contact_options'];


if($_POST["email"] != '') {
$ToEmail = '[removed for security]';
$email_from = $_POST["email"];
$EmailSubject = 'Online Information Request';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\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 .= "Information Required: ";
$MESSAGE_BODY .= $contact_options_msg;

// Validate the email address entered by the user
if(!filter_var($email_from, FILTER_VALIDATE_EMAIL)) {
// Invalid email address
die("The email address entered is invalid.");
}
// 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('There has been an error sending your message. Please try later.');
exit();
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum