changed docs to say DEPRECATED in favour of Email::MIME::Kit or Catalyst::View::Email...
[catagits/Catalyst-Plugin-Email.git] / README
CommitLineData
5a5a0df4 1NAME
921db5d4 2 Catalyst::Plugin::Email - (DEPRECATED) Send emails with Catalyst
5a5a0df4 3
4SYNOPSIS
921db5d4 5
6 # please use Email::MIME::Kit or Catalyst::View::Email::Template instead
7
5a5a0df4 8 use Catalyst 'Email';
9
95b3de58 10 __PACKAGE__->config->{email} = [qw/SMTP smtp.oook.de/];
5a5a0df4 11
12 $c->email(
13 header => [
14 From => 'sri@oook.de',
15 To => 'sri@cpan.org',
16 Subject => 'Hello!'
17 ],
18 body => 'Hello sri'
19 );
20
21DESCRIPTION
22 Send emails with Catalyst and Email::Send and Email::MIME::Creator.
23
95b3de58 24USING WITH A VIEW
25 A common practice is to handle emails using the same template language
26 used for HTML pages. This can be accomplished by pairing this plugin
27 with Catalyst::Plugin::SubRequest.
28
29 Here is a short example of rendering an email from a Template Toolkit
30 source file. The call to $c->subreq makes an internal call to the
31 render_email method just like an external call from a browser. The
32 request will pass through the end method to be processed by your View
33 class.
34
35 sub send_email : Local {
36 my ( $self, $c ) = @_;
37
38 $c->email(
39 header => [
40 To => 'me@localhost',
41 Subject => 'A TT Email',
42 ],
43 body => $c->subreq( '/render_email' ),
44 );
45 # redirect or display a message
46 }
47
48 sub render_email : Local {
49 my ( $self, $c ) = @_;
50
51 $c->stash(
52 names => [ qw/andyg sri mst/ ],
53 template => 'email.tt',
54 );
55 }
56
57 And the template:
58
59 [%- FOREACH name IN names -%]
60 Hi, [% name %]!
61 [%- END -%]
62
63 --
64 Regards,
65 Us
66
67 Output:
68
69 Hi, andyg!
70 Hi, sri!
71 Hi, mst!
72
73 --
74 Regards,
75 Us
76
77METHODS
78 email
5a5a0df4 79SEE ALSO
95b3de58 80 Catalyst, Catalyst::Plugin::SubRequest, Email::Send,
81 Email::MIME::Creator
5a5a0df4 82
83AUTHOR
84 Sebastian Riedel, "sri@cpan.org"
85
86COPYRIGHT
87 This program is free software, you can redistribute it and/or modify it
88 under the same terms as Perl itself.
89