.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Catalyst::View::Email::Template 3pm" .TH Catalyst::View::Email::Template 3pm 2024-03-04 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Catalyst::View::Email::Template \- Send Templated Email from Catalyst .SH SYNOPSIS .IX Header "SYNOPSIS" Sends templated mail, based upon your default view. It captures the output of the rendering path, slurps in based on mime-types and assembles a multi-part email using Email::MIME::Creator and sends it out. .SH CONFIGURATION .IX Header "CONFIGURATION" WARNING: since version 0.10 the configuration options slightly changed! .PP Use the helper to create your view: .PP .Vb 1 \& $ script/myapp_create.pl view Email::Template Email::Template .Ve .PP For basic configuration look at "CONFIGURATION" in Catalyst::View::Email. .PP In your app configuration (example in YAML): .PP .Vb 10 \& View::Email::Template: \& # Optional prefix to look somewhere under the existing configured \& # template paths. \& # Default: none \& template_prefix: email \& # Define the defaults for the mail \& default: \& # Defines the default view used to render the templates. \& # If none is specified neither here nor in the stash \& # Catalysts default view is used. \& # Warning: if you don\*(Aqt tell Catalyst explicit which of your views should \& # be its default one, C::V::Email::Template may choose the wrong one! \& view: TT .Ve .SH "SENDING EMAIL" .IX Header "SENDING EMAIL" Sending email works just like for Catalyst::View::Email but by specifying the template instead of the body and forwarding to your Email::Template view: .PP .Vb 2 \& sub controller : Private { \& my ( $self, $c ) = @_; \& \& $c\->stash\->{email} = { \& to => \*(Aqjshirley@gmail.com\*(Aq, \& cc => \*(Aqabraxxa@cpan.org\*(Aq, \& from => \*(Aqno\-reply@foobar.com\*(Aq, \& subject => \*(AqI am a Catalyst generated email\*(Aq, \& template => \*(Aqtest.tt\*(Aq, \& content_type => \*(Aqmultipart/alternative\*(Aq \& }; \& \& $c\->forward( $c\->view(\*(AqEmail::Template\*(Aq) ); \& } .Ve .PP Alternatively if you want more control over your templates you can use the following idiom to override the defaults. If charset and encoding given, the body become properly encoded. .PP .Vb 10 \& templates => [ \& { \& template => \*(Aqemail/test.html.tt\*(Aq, \& content_type => \*(Aqtext/html\*(Aq, \& charset => \*(Aqutf\-8\*(Aq, \& encoding => \*(Aqquoted\-printable\*(Aq, \& view => \*(AqTT\*(Aq, \& }, \& { \& template => \*(Aqemail/test.plain.mason\*(Aq, \& content_type => \*(Aqtext/plain\*(Aq, \& charset => \*(Aqutf\-8\*(Aq, \& encoding => \*(Aqquoted\-printable\*(Aq, \& view => \*(AqMason\*(Aq, \& } \& ] .Ve .SH "HANDLING ERRORS" .IX Header "HANDLING ERRORS" See "HANDLING ERRORS" in Catalyst::View::Email. .SH METHODS .IX Header "METHODS" .IP generate_part 4 .IX Item "generate_part" Generates a MIME part to include in the email. Since the email is template based every template piece is a separate part that is included in the email. .IP process 4 .IX Item "process" The process method is called when the view is dispatched to. This creates the multipart message and then sends the message contents off to Catalyst::View::Email for processing, which in turn hands off to Email::Sender::Simple. .SH TODO .IX Header "TODO" .SS ATTACHMENTS .IX Subsection "ATTACHMENTS" There needs to be a method to support attachments. What I am thinking is something along these lines: .PP .Vb 9 \& attachments => [ \& # Set the body to a file handle object, specify content_type and \& # the file name. (name is what it is sent at, not the file) \& { body => $fh, name => "foo.pdf", content_type => "application/pdf" }, \& # Or, specify a filename that is added, and hey, encoding! \& { filename => "foo.gif", name => "foo.gif", content_type => "application/pdf", encoding => "quoted\-printable" }, \& # Or, just a path to a file, and do some guesswork for the content type \& "/path/to/somefile.pdf", \& ] .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" .SS "Catalyst::View::Email \- Send plain boring emails with Catalyst" .IX Subsection "Catalyst::View::Email - Send plain boring emails with Catalyst" .SS "Catalyst::Manual \- The Catalyst Manual" .IX Subsection "Catalyst::Manual - The Catalyst Manual" .SS "Catalyst::Manual::Cookbook \- The Catalyst Cookbook" .IX Subsection "Catalyst::Manual::Cookbook - The Catalyst Cookbook" .SH AUTHORS .IX Header "AUTHORS" J. Shirley .PP Simon Elliott .PP Alexander Hartmaier .SH LICENSE .IX Header "LICENSE" This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.