문제

For some reason when I send an email message, the HTML is still being displayed in plain text. Can someone please tell me what I'm doing wrong here?

Here is the code:

            $to = $_SESSION['customer_email']; 
            $from = "noreplay@mysite.com";
            $subject = "Confirmation for Appointment on ".$_SESSION['display_date'];

            $headers = "From: ".$from."\r\n"; 
            $headers .= "Content-type: text/html; charseet=UTF-8;\r\n";
            $headers .= "MIME-Version: 1.0;\r\n"; 

              $message =  "<p>Thank you".$_SESSION['firstname']." for booking online. Your appointment has been confirmed and is scheduled for <strong>".$_SESSION['display_date']."</strong> between the hours of <strong>".$_SESSION['display_time']."</strong>.</p><p>  Please expect our crew to arrive between your two hour arrival window.  You will receive a courtesy call when our crew is <span>15-30 minutes</span> away. A confirmation email has been sent to <strong>".$_SESSION['customer_email']."</strong>. </p><p> If you have any questions or need to make any changes to your appointment, please contact our office at <strong>1-800-333-1111</strong>.  Thank you for choosing Us!
</p>";


            if(mail($to, $subject, $message, $header ))
            {
                $msg = "Your message has been sent";
            }
도움이 되었습니까?

해결책 3

change your 'charseet' to

Content-Type: text/html; charset=ISO-8859-1\r\n

It appears nowadays you can use UTF-8

Content-Type: text/html; charset=UTF-8\r\n

and

if(mail($to, $subject, $message, $header))

to

if(mail($to, $subject, $message, $headers))

also mail's RETURN:

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

다른 팁

 $headers .= "Content-type: text/html; charseet=UTF-8;\r\n";

should be

 $headers .= "Content-type: text/html; charset=UTF-8;\r\n";

Two typos:

if(mail($to, $subject, $message, $header ))

should be

if(mail($to, $subject, $message, $headers ))

and in

$headers .= "Content-type: text/html; charseet=UTF-8;\r\n";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top