0
  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' . "\r\n" .
'Reply-To: info@limousinesworld.com' . "\r\n" .
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers  = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; '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  \n
Comments2:          $Comments2  \n
Name:               $Name  \n
Company:            $Company  \n
Country:            $Country  \n
Telephone:          $Telephone  \n
EMail:              $EMail  \n
When_need_limo:     $When_need_limo  \n";

$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;

}

?> 
Cedric .
  • 1
  • 1
  • possible duplicate of [How to fix "Headers already sent" error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – John Conde Jun 23 '15 at 17:20
  • different issue, i read the link you provided. thanks. – Cedric . Jun 23 '15 at 18:07
  • @Cedric. - seems like it is the exact same issue. Can you edit your answer to show the full header cannot be modified error message. – aphextwix Jun 23 '15 at 18:20

1 Answers1

0

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' . "\r\n";

Notice the . in front of =

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

JasonJensenDev
  • 2,377
  • 21
  • 30