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 | |
25650747 |
34 | sub email_app_config : Global('email_app_config') { |
35 | my ($self, $c, @args) = @_; |
36 | |
37 | my $time = $c->req->params->{time} || time; |
38 | |
39 | $c->stash->{email} = { |
40 | to => 'test-email@example.com', |
41 | from => 'no-reply@example.com', |
42 | subject => 'Email Test', |
43 | body => "Email Sent at: $time" |
44 | }; |
45 | |
46 | $c->forward('TestApp::View::Email::AppConfig'); |
47 | |
48 | if ( scalar( @{ $c->error } ) ) { |
49 | $c->res->status(500); |
50 | $c->res->body('Email Failed'); |
51 | } else { |
52 | $c->res->body('Plain Email Ok'); |
53 | } |
54 | } |
55 | |
82300460 |
56 | sub template_email : Global('template_email') { |
57 | my ($self, $c, @args) = @_; |
58 | |
59 | $c->stash->{time} = $c->req->params->{time} || time; |
60 | |
61 | $c->stash->{email} = { |
fd0033bc |
62 | to => 'test-email@example.com', |
63 | from => 'no-reply@example.com', |
82300460 |
64 | subject => 'Just a test', |
06afcdbc |
65 | # content_type => 'multipart/alternative', |
82300460 |
66 | templates => [ |
06afcdbc |
67 | { |
68 | view => 'TT', |
69 | template => 'text_plain/test.tt', |
70 | content_type => 'text/plain', |
71 | }, |
72 | { |
73 | view => 'TT', |
74 | template => 'text_html/test.tt', |
75 | content_type => 'text/html', |
76 | }, |
77 | ], |
82300460 |
78 | }; |
79 | |
80 | $c->forward('TestApp::View::Email::Template'); |
81 | |
82 | if ( scalar( @{ $c->error } ) ) { |
83 | $c->res->status(500); |
84 | $c->res->body('Template Email Failed'); |
85 | } else { |
86 | $c->res->body('Template Email Ok'); |
87 | } |
88 | } |
89 | |
8b10ee55 |
90 | sub template_email_app_config : Global('template_email_app_config') { |
91 | my ($self, $c, @args) = @_; |
92 | |
93 | $c->stash->{time} = $c->req->params->{time} || time; |
94 | |
95 | $c->stash->{template_email} = { |
96 | to => 'test-email@example.com', |
97 | from => 'no-reply@example.com', |
98 | subject => 'Just a test', |
06afcdbc |
99 | # content_type => 'multipart/alternative', |
8b10ee55 |
100 | templates => [ |
06afcdbc |
101 | { |
102 | template => 'text_plain/test.tt', |
103 | content_type => 'text/plain', |
104 | }, |
105 | { |
106 | template => 'text_html/test.tt', |
107 | content_type => 'text/html', |
108 | }, |
109 | ], |
8b10ee55 |
110 | }; |
111 | |
112 | $c->forward('TestApp::View::Email::Template::AppConfig'); |
113 | |
114 | if ( scalar( @{ $c->error } ) ) { |
115 | $c->res->status(500); |
116 | $c->res->body('Template Email Failed'); |
117 | } else { |
118 | $c->res->body('Template Email Ok'); |
119 | } |
120 | } |
121 | |
122 | sub mason_email : Global('mason_email') { |
123 | my ($self, $c, @args) = @_; |
124 | |
125 | $c->stash->{time} = $c->req->params->{time} || time; |
126 | |
127 | $c->stash->{email} = { |
128 | to => 'test-email@example.com', |
129 | from => 'no-reply@example.com', |
130 | subject => 'Just a test', |
131 | content_type => 'multipart/alternative', |
132 | templates => [ |
06afcdbc |
133 | { |
134 | template => 'text_plain/test.tt', |
135 | content_type => 'text/plain', |
136 | }, |
137 | { |
138 | template => 'text_html/test.tt', |
139 | content_type => 'text/html', |
140 | }, |
141 | ], |
8b10ee55 |
142 | }; |
143 | |
144 | $c->forward('TestApp::View::Email::Template'); |
145 | |
146 | if ( scalar( @{ $c->error } ) ) { |
147 | $c->res->status(500); |
148 | $c->res->body('Mason Email Failed'); |
149 | } else { |
150 | $c->res->body('Mason Email Ok'); |
151 | } |
152 | } |
153 | |
154 | |
82300460 |
155 | 1; |