• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Catalyst/Plugin/H12-Aug-2015-19221

maint/H12-Aug-2015-64

t/H12-Aug-2015-64

xt/H12-Aug-2015-1610

ChangesH A D12-Aug-2015807 3323

MANIFESTH A D12-Aug-2015388 1211

META.jsonH A D12-Aug-20151.7 KiB6765

META.ymlH A D12-Aug-2015974 3634

Makefile.PLH A D12-Aug-20152.5 KiB7763

READMEH A D12-Aug-20153.9 KiB145115

README

1NAME
2    Catalyst::Plugin::Email - (DEPRECATED) Send emails with Catalyst
3
4SYNOPSIS
5        # please use Email::MIME::Kit or Catalyst::View::Email::Template instead
6
7        use Catalyst 'Email';
8
9        __PACKAGE__->config->{email} = [qw/SMTP smtp.oook.de/];
10
11        $c->email(
12            header => [
13                From    => 'sri@oook.de',
14                To      => 'sri@cpan.org',
15                Subject => 'Hello!'
16            ],
17            body => 'Hello sri'
18        );
19
20DESCRIPTION
21    Send emails with Catalyst and Email::Send and Email::MIME::Creator.
22
23CONFIGURATION
24    "config" accepts the same options as Email::Send.
25
26    To send using the system's "sendmail" program, set "config" like so:
27
28        __PACKAGE__->config->{email} = ['Sendmail'];
29
30    To send using authenticated SMTP:
31
32        __PACKAGE__->config->{email} = [
33            'SMTP',
34            'smtp.myhost.com',
35            username => $USERNAME,
36            password => $PASSWORD,
37        ];
38
39    For different methods of sending emails, and appropriate "config"
40    options, see Email::Send::NNTP, Email::Send::Qmail, Email::Send::SMTP
41    and Email::Send::Sendmail.
42
43METHODS
44  email
45    "email()" accepts the same arguments as Email::MIME::Creator's
46    "create()".
47
48        $c->email(
49            header => [
50                To      => 'me@localhost',
51                Subject => 'A TT Email',
52            ],
53            body => $c->subreq( '/render_email' ),
54        );
55
56    To send a multipart message, include a "parts" argument containing an
57    arrayref of Email::MIME objects.
58
59        my @parts = (
60            Email::MIME->create(
61                attributes => {
62                    content_type => 'application/pdf',
63                    encoding     => 'quoted-printable',
64                    name         => 'report.pdf',
65                },
66                body => $FILE_DATA,
67            ),
68            Email::MIME->create(
69                attributes => {
70                    content_type => 'text/plain',
71                    disposition  => 'attachment',
72                    charset      => 'US-ASCII',
73                },
74                body => $c->subreq( '/render_email' ),
75            ),
76        );
77
78        $c->email(
79            header => [
80                To      => 'me@localhost',
81                Subject => 'A TT Email',
82            ],
83            parts => \@parts,
84        );
85
86USING WITH A VIEW
87    A common practice is to handle emails using the same template language
88    used for HTML pages. If your view supports the 'render' method (Like the
89    TT view does), you just set the body like this: $c->email( header => [
90    To => 'me@localhost', Subject => 'A TT Email', ], body =>
91    $c->view('TT')->render($c,'mytemplate.tt'), }
92
93    If your view doesn't support render, you can just forward to it, then
94    reset the body like this:
95
96        sub send_email : Local {
97            my ( $self, $c ) = @_;
98            {
99            local $c->stash->{names}   = [ qw/andyg sri mst/ ],
100            local $c->stash->{template}= 'mytemplate.tt';
101            $c->forward($c->view('MyView'));
102            $c->email(
103                header => [
104                    To      => 'me@localhost',
105                    Subject => 'A TT Email',
106                ],
107                body => $c->res->body,
108            );
109            $c->res->body(undef);
110            }
111        }
112
113    And the template:
114
115        [%- FOREACH name IN names -%]
116        Hi, [% name %]!
117        [%- END -%]
118
119        --
120        Regards,
121        Us
122
123    Output:
124
125        Hi, andyg!
126        Hi, sri!
127        Hi, mst!
128
129        --
130        Regards,
131        Us
132
133SEE ALSO
134    Catalyst, Catalyst::Plugin::SubRequest, Email::Send,
135    Email::MIME::Creator
136
137AUTHOR
138    Sebastian Riedel, "sri@cpan.org" Andy Grundman Carl Franks Marcus
139    Ramberg "mramberg@cpan.org"
140
141COPYRIGHT
142    This program is free software, you can redistribute it and/or modify it
143    under the same terms as Perl itself.
144
145