[Typo3] html mailer and stylesheets

Cédric CHAMPEAU cedric.champeau at e-manation.com
Fri Mar 25 10:43:33 CET 2005


Hi again,

I've finally found a workaround for the Outlook strange behaviour, that I
explained after my patch was done : you need to append raw html content in
your newsletter that includes every style defined in your CSS which has an
image. This prevents Outlook from showing attachments for unused styles,
and, therefore, allows you to create a single template with every styles.
Here's an example of what I've added to my newsletter in order to get rid of
that behaviour :

<div style="visibility: hidden; position:absolute; left:0; top:0; width:0;
">
<div class="pdf"><a></a></div>
<div class="lien_fleche"><a></a></div>
<div class="Top"></div>
<div class="colonneInt"><a class="loupe"></a></div>
<div class="colonneInt"><a class="texte"></a></div>
<div class="end"><a></a></div>
<div class="Top"><a></a></div>
<div class="contentSousNav"><a></a></div>
<div class="pop"><a></a></div>
<div class="ext"><a></a></div>
<div class="ext2"><a></a></div>
<div class="contentSousNav2"><a></a></div>
<h3></h3>
</div>

Unfortunately, this does not solve the problem with thunderbird, which does
not seem to recognize embedded images in styles (i.e : .mystyle {
background-image: url(cid:fgdgfdgfgfdhgjhfdjghkjfhdg) })

Sincerely,

Cédric Champeau 

> -----Message d'origine-----
> De : typo3-english-bounces at lists.netfielders.de 
> [mailto:typo3-english-bounces at lists.netfielders.de] De la 
> part de Cédric CHAMPEAU
> Envoyé : mercredi 23 mars 2005 11:56
> À : 'TYPO3 English'
> Objet : [Typo3] html mailer and stylesheets
> 
> Hi,
>  
> I had the following problem with Outlook : when I sent a 
> newsletter from
> Typo3 based on CSS stylesheets, the images used in the 
> stylesheet were not
> displayed unless Outlook was configured to display all images 
> whatever the
> site. The reason is that Outlook disables image downloading 
> by default for
> "untrusted" sources. (Newsletter are looking good in Thunderbird).
>  
> I did notice that the newsletter extension did embed the 
> images into the
> e-mail, but there was still a problem with embedded 
> stylesheets (stylesheets
> defined *into* the html file): images did not get displayed. This is a
> problem where you define styles like this :
>  
> .mystyle
> { background-image: url(/path/to/my/image); }
>  
> Therefore, I modified the t3lib_htmlmail class in order to 
> embed images that
> were defined into embedded stylesheets. It's a dirty trick, 
> which works for
> me. Here's the code, don't know if it should be submitted as 
> a bug or not :
>  
> Insert line 841, file typo3/t3lib/class.t3lib_htmlmailer.php
>  
>   // PATCH BEGIN
>   // Date : 2005-03-23
>   // Author : Cedric CHAMPEAU, e-manation
>   // Description : quick and dirty fix to embed images linked 
> into embedded
> stylesheets
>   preg_match_all("/url\((.*)\)/", $html_code, 
> $allcodepieces); // looks for
> url(/path/to/file) matches in the html code. Ugly because to 
> simple to be
> perfect matcher
>   $codepieces=$allcodepieces[1];
>     $pieces = count($codepieces);
>   for($i=0; $i < $pieces; $i++) {
>       $imageData=array();
>     $imageData["ref"]=$codepieces[$i];
>     
> $imageData["quotes"]=(substr($codepieces[$i],strpos($codepieces[$i],
> $imageData["ref"])-1,1)=='"')?'"':'';  // Finds out if the 
> value had quotes
> around it
>       $imageData["subst_str"] =
> $imageData["quotes"].$imageData["ref"].$imageData["quotes"]; 
> // subst_str is
> the string to look for, when substituting lateron
>     if ($imageData["ref"] &&
> !strstr($this->image_fullpath_list,"|".$imageData["subst_str"]."|")) {
>      $this->image_fullpath_list.="|".$imageData["subst_str"]."|";
>      $imageData["absRef"] = $this->absRef($imageData["ref"]);
>      $this->theParts["html"]["media"][]=$imageData;
>     }    
>   }
>   // PATCH END
>  
>  
> I still have one problem, and I've not yet found if it was just that I
> missed another part of the code to patch : the images defined 
> into embedded
> stylesheets appear as attached files in Outlook, while the 
> newsletter is now
> broken in Thunderbird (images defined into the stylesheet do 
> not appear
> anymore, and Thunderbird displays many attached parts).
>  
> Cédric Champeau
>  
> _______________________________________________
> Typo3-english mailing list
> Typo3-english at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english
> 
> 




More information about the TYPO3-english mailing list