App-Basis-Email
view release on metacpan or search on metacpan
lib/App/Basis/Email.pm view on Meta::CPAN
# Basic Markdown

That was an inlined image
## level2 header
* bullet
* sub-bullet
### level3 header
EOD
my $html = markdown($markdown);
my $mail = App::Basis::Email->new( hostname => 'my.email.server', port => 25 ) ;
my $status = $mail->send(
from => 'fred@fred.test.fred',
to => 'fred@fred.test.fred',
subject => 'test HTML email, with inline images',
html => $html
);
=head1 DESCRIPTION
Sending email should be simple, sending formatted email should be simple too.
I just want to be able to say send this thing via this process.
This module provides that, a way to simply send email (plain/html or markdown) via
either a SMTP or sendmail target.
Obviously I do nothing new, just wrap around existing modules, to make life simple.
=head1 AUTHOR
kevin mulholland
=head1 Notes
if you want templating then do it outside of this module and pass the formatted
HTML/markdown in
=head1 See Also
To create email I use L<Email::MIME::CreateHTML>, you may need to force this to
install it as there is a slight test bug
To send email I use L<Email::Sender::Simple> with L<Email::Sender::Transport::SMTP> and L<Email::Sender::Transport::Sendmail>
Markdown processing is done with L<Text::Markdown>
=over 4
=cut
package App::Basis::Email;
$App::Basis::Email::VERSION = '0.3';
use 5.010;
use warnings;
use strict;
use Moo;
use Try::Tiny;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP qw();
use Email::Sender::Transport::Sendmail;
use Email::MIME::CreateHTML;
use Text::Markdown 'markdown';
use HTML::Restrict;
# ----------------------------------------------------------------------------
# what host name are we connecting to, defaults to localhost
has host => ( is => 'ro', );
# on what port
has port => (
is => 'ro',
default => sub { 25 },
);
# do we want to use SSL
has ssl => (
is => 'ro',
default => sub { 0 },
);
# SSL needs a user
has user => (
is => 'ro',
default => sub { '' },
);
# SSL user needs a password
has passwd => (
is => 'ro',
default => sub { '' },
);
# how should we send things, either SMTP or Sendmail (default)
has transport => (
is => 'ro',
writer => '_set_transport'
);
# if using sendmail having the path to the binary would help
has sendmail_path => ( is => 'ro' );
# we want a testing mode that will not send email, so that we can get output
# and use it for validation in our test scripts
has testing => ( is => 'ro' );
# ----------------------------------------------------------------------------
has sender => (
is => 'ro',
init_arg => undef, # dont allow setting in constructor
writer => '_set_sender'
);
# ----------------------------------------------------------------------------
=item new
( run in 1.650 second using v1.01-cache-2.11-cpan-39bf76dae61 )