sub create_mime_email {
# Parse arguments
my $template_path = shift or die q~No template file found in provided 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;
}
####
{
"header": [
{ "Subject": "MIME e-mail test" },
{ "From": "John Doe " },
{ "To": "Jane Doe " }
],
"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" }
}
]
}
####
Hello World!