NAME
Email::MIME::Kit - build messages from templates
VERSION
version 2.102013
SYNOPSIS
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 ...
});
$transport->send($email, { ... });
DESCRIPTION
Email::MIME::Kit is a templating system for email messages. Instead of trying to be yet another templating system for chunks of text, it makes it easy to build complete email messages.
It handles the construction of multipart messages, text and HTML alternatives, attachments, interpart linking, string encoding, and parameter validation.
Although nearly every part of Email::MIME::Kit is a replaceable component, the stock configuration is probably enough for most use. A message kit will be stored as a directory that might look like this:
sample.mkit/
manifest.json
body.txt
body.html
logo.jpg
The manifest file tells Email::MIME::Kit how to put it all together, and might look something like this:
{
"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" } ]
}
]
}
Please note: the assembly of HTML documents as multipart/related bodies will probably be simplified with an alternate assembler in the near future.
The above manifest would build a multipart alternative message. GUI mail clients would see a rendered HTML document with the logo graphic visible from the attachment. Text mail clients would see the plaintext.
Both the HTML and text parts would be rendered using the named renderer, which here is Template-Toolkit.
The message would be assembled and returned as an Email::MIME object, just as easily as suggested in the "SYNOPSIS" above.
PERL EMAIL PROJECT
This module is maintained by the Perl Email Project
http://emailproject.perl.org/wiki/Email::MIME::Kit
AUTHOR
This code was written in 2009 by Ricardo SIGNES. It was based on a previous implementation by Hans Dieter Pearcey written in 2006.
The development of this code was sponsored by Pobox.com. Thanks, Pobox!
AUTHOR
Ricardo Signes <rjbs@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.