1

i am having a php script to sent confirmation mail after registering in a form from my linux hosting. The confirmation mail is HTML formatted using CSS. But it only shows HTML code in Gmail But it works perfectly on other mail clients

 <?php
$yourname='ijaz';
$youremail = 'ijazblahblah@gmail.com';
$id = 150456;
    $subject = "Confirmation";
        $message = '<html><body>';
$message .= '<h1 style="color:#f40;">Hi Jane!</h1>';
$message .= '<p style="color:#080;font-size:18px;">Will you marry me?</p>';
$message .= '</body></html>';
        $headers = 'From: blah<info@blah.in>' . "\n";
        mail($youremail,$subject,$message,$headers);


        ?>

the mail i get is like this in Gmail:

<html><body><h1 style="color:#f40;">Hi Jane!</h1><p style="color:#080;font-size:18px;">Will you marry me?</p></body></html>
Ijas
  • 93
  • 1
  • 11

2 Answers2

2

You have to include the header that tells GMail to render it as HTML:

$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
sorak
  • 2,607
  • 2
  • 16
  • 24
0

Add content-type. For html in mail.

 $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
Arsalan Akhtar
  • 395
  • 2
  • 15