Commit | Line | Data |
82300460 |
1 | package # Hide from PAUSE |
2 | TestApp::Controller::Root; |
3 | |
4 | use base qw(Catalyst::Controller); |
5 | |
6 | sub default : Private { |
7 | my ( $self, $c ) = @_; |
8 | |
9 | $c->res->body(qq{Nothing Here}); |
10 | } |
11 | |
12 | sub email : Global('email') { |
13 | my ($self, $c, @args) = @_; |
14 | |
15 | my $time = $c->req->params->{time} || time; |
16 | |
17 | $c->stash->{email} = { |
fd0033bc |
18 | to => 'test-email@example.com', |
19 | from => 'no-reply@example.com', |
82300460 |
20 | subject => 'Email Test', |
21 | body => "Email Sent at: $time" |
22 | }; |
23 | |
24 | $c->forward('TestApp::View::Email'); |
25 | |
26 | if ( scalar( @{ $c->error } ) ) { |
27 | $c->res->status(500); |
28 | $c->res->body('Email Failed'); |
29 | } else { |
30 | $c->res->body('Plain Email Ok'); |
31 | } |
32 | } |
33 | |
34 | sub template_email : Global('template_email') { |
35 | my ($self, $c, @args) = @_; |
36 | |
37 | $c->stash->{time} = $c->req->params->{time} || time; |
38 | |
39 | $c->stash->{email} = { |
fd0033bc |
40 | to => 'test-email@example.com', |
41 | from => 'no-reply@example.com', |
82300460 |
42 | subject => 'Just a test', |
43 | content_type => 'multipart/alternative', |
44 | templates => [ |
45 | qw{text_plain/test.tt}, |
46 | qw{text_html/test.tt} |
47 | ] |
48 | }; |
49 | |
50 | $c->forward('TestApp::View::Email::Template'); |
51 | |
52 | if ( scalar( @{ $c->error } ) ) { |
53 | $c->res->status(500); |
54 | $c->res->body('Template Email Failed'); |
55 | } else { |
56 | $c->res->body('Template Email Ok'); |
57 | } |
58 | } |
59 | |
60 | 1; |