html电子邮件显示提交时的HTML代码,并且不会将客户端发送到thank_you.php页面

  1. Right now email is being sent but email received shows the html codes in body of email, and

  2. thank you page does not launch (says "header cannot be modified...).

I would like client to receive an html email correctly AND show client a thank_you.php page I have already created.

Could you please help with corrections?

<?php

if($_POST["submit"]) 
{
    $webmaster="info@limousinesworld.com";
    $subject="Limousines Quote Request";
    $subject_client="Thank you for your Request";

    $ip = $_SERVER['REMOTE_ADDR'];  
    $ip2 =  $_SERVER["HTTP_X_FORWARDED_FOR"];
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else  ;

$headers = 'From: LimousinesWorld' . "
" .
'Reply-To: info@limousinesworld.com' . "
" .
$headers  = 'MIME-Version: 1.0' . "
";
$headers  = 'Content-type: text/html; charset=iso-8859-1' . "
"; 'X-
Mailer: PHP/';
$headers = "From: LimousinesWorld <info@limousinesworld.com>";      

$replyemail="info@limousinesworld.com";

$senderClient=$_REQUEST['EMail'];

$Comments1 = $_REQUEST['Comments1'] ;
$Comments2 = $_REQUEST['Comments2'] ;
$Name = $_REQUEST['Name'] ;
$Company = $_REQUEST['Company'] ;
$Telephone = $_REQUEST['Telephone'] ;
$EMail = $_REQUEST['EMail'] ;
$When_need_limo = $_REQUEST ['When_need_limo'] ;
$Country = $_REQUEST['Country'] ;


$mailBody= "
Comments1:          $Comments1  

Comments2:          $Comments2  

Name:               $Name  

Company:            $Company  

Country:            $Country  

Telephone:          $Telephone  

EMail:              $EMail  

When_need_limo:     $When_need_limo  
";

$mailBody_client= '

<html>

<body>
<h1><strong><span style="font-size:16px;"><span style="font-
family:arial,helvetica,sans-serif;">Thank you for your Limousine Quote   
Request on our website.</span></span></strong></h1>

<p><span style="font-size:16px;"><span style="font- 
family:arial,helvetica,sans-serif;"><strong>We will get back to you with  
very soon with: Prices, Pictures,&nbsp;Equipment and Options.</strong>
</span></span></p>

<p><span style="font-family:arial,helvetica,sans-serif;"><span style="font-  
size:16px;"><strong>Best regards,</strong></span></span></p>

<p><span style="font-family:arial,helvetica,sans-serif;"><span style="font-  
size:16px;"><strong>LimousinesWorld</strong></span></span></p>
</body>
</html>
';


mail($webmaster, $subject, $mailBody, $headers, $ip);

mail($senderClient, $subject_client, $mailBody_client, $headers);

header("Location: http://limousinesworld.com/thank_you.php");
exit;

}

?> 

One thing I that noticed right away is that you are not appending to your $header variable. Your code overwrites the $header variable each time. To fix this, you should do something like this:

$headers  .= 'MIME-Version: 1.0' . "
";

Notice the . in front of =

This makes it so that you append to the variable rather than overwrite it.