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

USING WITH A VIEW

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

SEE ALSO

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

AUTHOR

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