Mojolicious::Plugin::Email - It's a Mojolicious Plugin for sending emails (a work in progress).
# register plugin in your application
$self->plugin(Email => {
from => '"Administrator" <[email protected]>',
transport => Email::Sender::Transport::Sendmail->new('/path/to/sendmail'),
});
# use it in your controller
$self->email(
header => [
# if you set From here, it will overwrite the config 'from'
From => '"Administrator" <[email protected]>',
To => '"Some Name" <[email protected]>',
# this will overwrite the 'title' from email template
Subject => "Subject",
],
# this will overwrite the config transport
transport => Email::Sender::Transport::SMTP::TLS->new(
host => 'smtp_server',
username => 'username',
password => 'password',
port => port,
),
data => [
template => 'email/template_name',
info => 'Some useful data you need in your template'
],
content_type => 'text/html',
charset => 'utf8',
encoding => '8bit',
format => 'email',
);
# Your email template "templates/email/template_name.email.ep":
% layout 'email/default';
% title 'Subject';
<p><%= $data->{info} %></p>
# The default email layout "templates/layouts/email/default.email.ep":
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
Version 0.03
Raul Matei mailto:[email protected]
Copyright (C) 2012 by Raul Matei
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.