Hi monks,
I've been working on a module for work and in one part of it I need to generate an email object using Email::MIME::Kit.
Here are my requirements:
I've been looking for docs/tutorials/anything to help me with this for > 1 day now and I'm so frustrated...
If anyone can help me with this, I'd be eternally thankful!
Here's my code for the sub so far:
sub create_mime_email { # Parse arguments my $template_path = shift or die q~No template file found in provide +d path~; my $manifest_reader = shift // 'JSON'; # Load required modules use Email::MIME::Kit; my $kit = Email::MIME::Kit->new({ source => $template_path, manifest_reader => $manifest_reader, }); my $email = $kit->assemble(); return $email; }
... And the template code:
{ "header": [ { "Subject": "MIME e-mail test" }, { "From": "John Doe <john@gmail.com>" }, { "To": "Jane Doe <jane@gmail.com>" } ], "alternatives": [ { "container_type": "multipart/related", "type": "text/html", "path": "better-alternative.html", "attributes": { "charset": "utf-8" }, "attachments": [ { "type": "image/jpeg", "path": "logo.jpg" } ] } ], "attachments": [ { "type": "application/pdf", "path": "bogus-report.pdf", "attributes": { "filename": "report.pdf" } } ] }
... And the contents of the html template file:
<html> <body> Hello World! <img src='cid:[% cid_for("logo.jpg") %]' /> </body> </html>
In reply to Need help generating an HTML mail with Email::MIME::Kit by xMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |