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 = "[email protected]";
// subject
$subject = "Test mail";
// message
$message = file_get_contents("index.html");
// from
$from = "[email protected]";
// 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.
Google, Outlook, Yahoo all the major email service providers do not allow CSS external files. It may sound antiquated that they have opted for inline styles and tables to render a proper email message with any styling.
It may be tedious to code but companies like https://litmus.com/ and envato will help with some templates and formatting issues.
my 2¢'s: email providers can't trust all sources of information being sent and so this is a way of keeping the malicious code at bay.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With