Subject: | Email::MIME::Kit::Assember::Standard - cid_for callback includes brackets |
Date: | Fri, 10 Jul 2009 16:58:00 -0700 |
To: | "bug-Email-MIME-Kit [...] rt.cpan.org" <bug-Email-MIME-Kit [...] rt.cpan.org> |
From: | Jason Taylor <jataylor [...] expedia.com> |
Email::MIME::Kit::Assember::Standard - 2.091430
Perl v5.10.0 built for MSWin32-x86-multi-thread Binary build 1003 [285500] provided by ActiveState
Windows XP Pro SP2 - 32-bit
MS Outlook 2003
-----
Using the cid_for callback within an HTML template includes the brackets around the cid (e.g. <logo.jgp>). This causes the image to not appear when reading the e-mail as rendered by MS Outlook 2003. Changing the callback to eliminate the brackets solves the problem.
-----
Code like:
use Email::MIME::Kit;
my $kit = Email::MIME::Kit->new({ source => 'mkits/sample.mkit' });
my $email = $kit->assemble({
account => $new_signup,
verification_code => $token,
... and any other template vars ...
});
-----
Manifest like:
{
"renderer": "TT",
"header": [
{ "From": "WY Corp <noreplies@wy.example.com>" },
{ "Subject": "Welcome aboard, [% recruit.name %]!" }
],
"alternatives": [
{ "type": "text/plain", "path": "body.txt" },
{
"type": "text/html",
"path": "body.html",
"container_type": "multipart/related",
"attachments": [ { "type": "image/jpeg", "path": "logo.jpg" } ]
}
]
}
-----
HTML Template like:
<html>
<body>
<p>Some Text<p>
<img src="[% cid_for('logo.jpg') %]">
<body>
<html>
-----
Fix for the render sub is (I'm sure there's a more elegant way to do this):
sub render {
my ($self, $input_ref, $stash) = @_;
local $stash->{cid_for} = sub { (my $cid = $self->cid_for_path($_[0])) =~ s/^<|>$//g; return $cid; };
return $input_ref unless my $renderer = $self->renderer;
return $renderer->render($input_ref, $stash);
}