snoofkin
snoofkin

Reputation: 8895

MIME::Lite and inlined CSS images

I have the following code:

#!/root/bin/perl
use strict;
use warnings;
use MIME::Lite;


my $data =<<"DATA";
<!DOCTYPE HTML PUBLIC >
<html>
<head>
<style>

#header {
  background-image: url("cid:background.png");
}
</style>


</head>
<body>
<div id="header"></div>
<img src="cid:logo_header.png"></img>
</body>
</html>

DATA

my $msg = MIME::Lite->new(
         To      => '[email protected]',
         Subject => 'title',
         Type    => 'text/html',
         Data    => $data
    );
    $msg->attach(
        Type => 'image/png',
        Id   => 'logo_header.png',
        Path => 'logo_header.png',
    );
   $msg->attach( Type => 'image/png',
                 Id   => 'background.png',
                 Path => 'background.png'); 
   $msg->send();

Seems like it doesn't display the image inside the CSS (does this module even parses non HTML tags?) when I place the image as a background or <img> it displays it fine. I even tried turning background-image: url("cid:background.png"); into background-image: url("background.png"); but this didn't work as well.

any idea?

Upvotes: 0

Views: 960

Answers (1)

Richard Huxton
Richard Huxton

Reputation: 22893

I think you'll be wanting CSS::Inliner. Specifically designed for this issue.

There are many limitations of html email clients. If you google around the subject you'll see that they all have their own charming quirks.

Upvotes: 1

Related Questions