1Catalyst::Plugin::EmailU(s3e)r Contributed Perl DocumentaCtaitoanlyst::Plugin::Email(3)
2
3
4

NAME

6       Catalyst::Plugin::Email - (DEPRECATED) Send emails with Catalyst
7

SYNOPSIS

9           # please use Email::MIME::Kit or Catalyst::View::Email::Template instead
10
11           use Catalyst 'Email';
12
13           __PACKAGE__->config->{email} = [qw/SMTP smtp.oook.de/];
14
15           $c->email(
16               header => [
17                   From    => 'sri@oook.de',
18                   To      => 'sri@cpan.org',
19                   Subject => 'Hello!'
20               ],
21               body => 'Hello sri'
22           );
23

DESCRIPTION

25       Send emails with Catalyst and Email::Send and Email::MIME::Creator.
26

CONFIGURATION

28       "config" accepts the same options as Email::Send.
29
30       To send using the system's "sendmail" program, set "config" like so:
31
32           __PACKAGE__->config->{email} = ['Sendmail'];
33
34       To send using authenticated SMTP:
35
36           __PACKAGE__->config->{email} = [
37               'SMTP',
38               'smtp.myhost.com',
39               username => $USERNAME,
40               password => $PASSWORD,
41           ];
42
43       For different methods of sending emails, and appropriate "config"
44       options, see Email::Send::NNTP, Email::Send::Qmail, Email::Send::SMTP
45       and Email::Send::Sendmail.
46

METHODS

48   email
49       "email()" accepts the same arguments as Email::MIME::Creator's
50       "create()".
51
52           $c->email(
53               header => [
54                   To      => 'me@localhost',
55                   Subject => 'A TT Email',
56               ],
57               body => $c->subreq( '/render_email' ),
58           );
59
60       To send a multipart message, include a "parts" argument containing an
61       arrayref of Email::MIME objects.
62
63           my @parts = (
64               Email::MIME->create(
65                   attributes => {
66                       content_type => 'application/pdf',
67                       encoding     => 'quoted-printable',
68                       name         => 'report.pdf',
69                   },
70                   body => $FILE_DATA,
71               ),
72               Email::MIME->create(
73                   attributes => {
74                       content_type => 'text/plain',
75                       disposition  => 'attachment',
76                       charset      => 'US-ASCII',
77                   },
78                   body => $c->subreq( '/render_email' ),
79               ),
80           );
81
82           $c->email(
83               header => [
84                   To      => 'me@localhost',
85                   Subject => 'A TT Email',
86               ],
87               parts => \@parts,
88           );
89

USING WITH A VIEW

91       A common practice is to handle emails using the same template language
92       used for HTML pages.  If your view supports the 'render' method (Like
93       the TT view does), you just set the body like this:
94         $c->email(
95            header => [
96               To      => 'me@localhost',
97               Subject => 'A TT Email',
98            ],
99            body => $c->view('TT')->render($c,'mytemplate.tt'),
100         }
101
102       If your view doesn't support render, you can just forward to it, then
103       reset the body like this:
104
105           sub send_email : Local {
106               my ( $self, $c ) = @_;
107               {
108               local $c->stash->{names}   = [ qw/andyg sri mst/ ],
109               local $c->stash->{template}= 'mytemplate.tt';
110               $c->forward($c->view('MyView'));
111               $c->email(
112                   header => [
113                       To      => 'me@localhost',
114                       Subject => 'A TT Email',
115                   ],
116                   body => $c->res->body,
117               );
118               $c->res->body(undef);
119               }
120           }
121
122       And the template:
123
124           [%- FOREACH name IN names -%]
125           Hi, [% name %]!
126           [%- END -%]
127
128           --
129           Regards,
130           Us
131
132       Output:
133
134           Hi, andyg!
135           Hi, sri!
136           Hi, mst!
137
138           --
139           Regards,
140           Us
141

SEE ALSO

143       Catalyst, Catalyst::Plugin::SubRequest, Email::Send,
144       Email::MIME::Creator
145

AUTHOR

147       Sebastian Riedel, "sri@cpan.org" Andy Grundman Carl Franks Marcus
148       Ramberg "mramberg@cpan.org"
149
151       This program is free software, you can redistribute it and/or modify it
152       under the same terms as Perl itself.
153
154
155
156perl v5.30.0                      2019-07-26        Catalyst::Plugin::Email(3)
Impressum