http://www.perlmonks.org?node_id=1199361


in reply to Re: Need help generating an HTML mail with Email::MIME::Kit
in thread Need help generating an HTML mail with Email::MIME::Kit

Well, I was having problems getting it to work in general.

I got a bit further yesterday night and ended up with this template manifest.json-file which now takes care of requirements 1 and 2:

{ "renderer": "TestRenderer", "header": [ { "Subject": "MIME e-mail test" }, { "From": "John Doe <john@doe.com.au>" }, { "To": "Jane Doe <jane@doe.com.au>" } ], "alternatives": [ { "attributes": { "content_type": "text/html", "charset": "utf-8" }, "body": "HTML goes <h3>HERE</h3><br>You can also use variables, +like this:<br>E.g. the variable friend = '[% friend %]' and gets rend +ered when the email object is created." } ], "attachments": [ { "type": "application/pdf", "path": "bogus-report.pdf", "attributes": { "filename": "report.pdf" } } ] }

I still don't know how to load a scalar/hash when creating the "kit". This is how that part of the code is looking right now:

my $kit = Email::MIME::Kit->new({ source => './dir/where/template/file/is', manifest_reader => 'JSON', }); my $email = $kit->assemble({ friend => 'xMonk', });