Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2011
    Location
    Essex, England
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Unusual email received from form submission

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

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Try removing the content-type: text/html line

  • Users who have thanked Adee for this post:

    jofield (11-20-2011)

  • #3
    New Coder
    Join Date
    Oct 2011
    Location
    Essex, England
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks Adee, that worked a treat!!!
    Yet another mistake to prove what a rookie I am

  • #4
    New Coder
    Join Date
    Oct 2011
    Location
    Essex, England
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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?

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


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •