Created
January 2, 2014 09:35
-
-
Save b-abctech/8216896 to your computer and use it in GitHub Desktop.
sending mail in text/html with Catalyst::View::Email::Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. first install module Catalyst::View::Email::Template, Catalyst::View::Email | |
# 2. create email template view | |
# 3. in config add these | |
View::Email::Template: | |
template_prefix: email | |
default: | |
view: HTML | |
content_type: text/html | |
# 4. in controller add something like this | |
=head2 mailshare | |
send mail controller | |
=cut | |
sub mailshare :Path('/mailshare') : Args(0) { | |
my ( $self, $c ) = @_; | |
$c->stash->{email} = { | |
to => '[email protected]', | |
from => '[email protected]', | |
subject => 'subject title', | |
template => 'mailshare.tt', | |
}; | |
$c->forward( $c->view('Email::Template') ); | |
$c->response->status(200); | |
$c->response->body(); | |
} | |
# 5. add email template file .tt in email folder eg 'email/mailshare.tt' | |
# 6. set template to use no wrapper [% META no_wrapper = 1 %] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment