NAME
Email::Simple::Markdown - simple email creation with auto text and html multipart body
VERSION
version 0.3.0
SYNOPSIS
use Email::Simple::Markdown;
my $email = Email::Simple::Markdown->create(
header => [
From => 'me@here.com',
To => 'you@there.com',
Subject => q{Here's a multipart email},
],
body => '[this](http://metacpan.org/search?q=Email::Simple::Markdown) is *amazing*',
);
print $email->as_string;
DESCRIPTION
Email::Simple::Markdown behaves almost exactly like Email::Simple, excepts for one detail: when its method as_string()
is invoked, the returned string representation of the email has multipart body with a text/plain element (the original body), and a text/html element, the markdown rendering of the text body.
The markdown convertion is done using Text::MultiMarkdown.
METHODS
Email::Simple::Markdown inherits all the methods if Email::Simple. In addition, it provides one more method: with_markdown.
create( ... )
Behaves like Email::Simple's create()
, but accepts the following additional arguments:
- markdown_engine => $module
-
See
markdown_engine_set
. If not given, defaults toauto
. - css => $stylesheet
-
If provided, the html part of the email will be prepended with the given stylesheet, wrapped by a css tag.
- pre_markdown_filter => sub { ... }
-
See
pre_markdown_filter_set
.
markdown_engine
Returns the markdown engine used by the object.
markdown_engine_set( $module )
Sets the markdown engine to be used by the object. Currently accepts auto
, Text::MultiMarkdown or Text::Markdown.
If not specified or set to auto
, the object will use the first markdown module it finds, in the order given in the previous paragraph.
css
Returns the cascading stylesheet that is applied to the html part of the email.
css_set( $stylesheet )
Sets the cascading stylesheet for the html part of the email to be $stylesheet.
$email->css_set( <<'END_CSS' );
p { color: red; }
pre { border-style: dotted; }
END_CSS
pre_markdown_filter_set( sub{ ... } );
Sets a filter to be run on the body before the markdown transformation is done. The body will be passed as $_
and should be modified in-place.
E.g., to add a header to the email:
$mail->pre_markdown_filter_set(sub {
s#^#<div id="header">My Corp <img src='..' /></div>#;
});
with_markdown()
Returns an Email::Abstract representation of the email, with its multipart body.
AUTHOR
Yanick Champoux <yanick@babyl.dyndns.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.