;D

miércoles, 11 de enero de 2012

Emogrifier: Innline CSS

Today i had to create a email and it uses HTML and CSS. I discovered Gmail and some mail clients doesn't handle css. I found a tool called Emogrifier that takes the HTML and CSS and outputs HTML with inner CSS. This is how i used it:


include_once("emogrifier.php"); // Download from http://www.pelagodesign.com/sidecar/emogrifier/
$myFile = "style.css"; // the filename or path to your stylesheet
$fh = fopen($myFile, 'r'); //opens the file 
$theCSS = fread($fh, filesize ($myFile) ); //stores the content of the file inside a variable 
fclose($fh); //close the file

$theHTML =" ... "; //the html

$fix = new Emogrifier($theHTML, $theCSS);
$newHTML = $fix->emogrify();


echo $newHTML; //outputs the new html

?>

This is a simple guide in how to use Emogrifier because i couldn't find one on google and i was in a hurry.

If something is missing or you got an idea, comment bellow

No hay comentarios:

Publicar un comentario

Comentada, su opinion es importante/Comment, your opinion is important.