Send HTML email including CSS style sheet via PHP

Viewed 34904

I want to send a HTML page that contains CSS stylesheet to an email account. The problem is that the CSS style sheet is not visible at all. Do I have to inline every CSS styling? It seems to be highly inefficient method. Any others ideas ?

Below is the PHP code for sending the email :

<?php
$to = "myaccount@gmail.com";

// subject
$subject = "Test mail";

// message
$message = file_get_contents("index.html");

// from
$from = "myaccount@gmail.com";

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= "From:" . $from;

// Mail it
mail($to,$subject,$message,$headers);

echo "Mail Sent.";
?>

I would greatly appreciate your help. Thanks in advance.

4 Answers
Related