Commit | Line | Data |
82300460 |
1 | package # Hide from PAUSE |
2 | TestApp::Controller::Root; |
3 | |
4 | use base qw(Catalyst::Controller); |
5 | |
beda8c31 |
6 | use Encode; |
7 | |
82300460 |
8 | sub default : Private { |
9 | my ( $self, $c ) = @_; |
10 | |
11 | $c->res->body(qq{Nothing Here}); |
12 | } |
13 | |
14 | sub email : Global('email') { |
15 | my ($self, $c, @args) = @_; |
16 | |
17 | my $time = $c->req->params->{time} || time; |
18 | |
19 | $c->stash->{email} = { |
fd0033bc |
20 | to => 'test-email@example.com', |
21 | from => 'no-reply@example.com', |
82300460 |
22 | subject => 'Email Test', |
23 | body => "Email Sent at: $time" |
24 | }; |
25 | |
26 | $c->forward('TestApp::View::Email'); |
27 | |
28 | if ( scalar( @{ $c->error } ) ) { |
29 | $c->res->status(500); |
30 | $c->res->body('Email Failed'); |
31 | } else { |
32 | $c->res->body('Plain Email Ok'); |
33 | } |
34 | } |
35 | |
25650747 |
36 | sub email_app_config : Global('email_app_config') { |
37 | my ($self, $c, @args) = @_; |
38 | |
39 | my $time = $c->req->params->{time} || time; |
40 | |
41 | $c->stash->{email} = { |
42 | to => 'test-email@example.com', |
43 | from => 'no-reply@example.com', |
44 | subject => 'Email Test', |
45 | body => "Email Sent at: $time" |
46 | }; |
47 | |
48 | $c->forward('TestApp::View::Email::AppConfig'); |
49 | |
50 | if ( scalar( @{ $c->error } ) ) { |
51 | $c->res->status(500); |
52 | $c->res->body('Email Failed'); |
53 | } else { |
54 | $c->res->body('Plain Email Ok'); |
55 | } |
56 | } |
57 | |
82300460 |
58 | sub template_email : Global('template_email') { |
59 | my ($self, $c, @args) = @_; |
60 | |
61 | $c->stash->{time} = $c->req->params->{time} || time; |
62 | |
63 | $c->stash->{email} = { |
ab4326b4 |
64 | to => 'test-email@example.com', |
65 | from => 'no-reply@example.com', |
66 | subject => 'Just a test', |
67 | content_type => 'multipart/alternative', |
82300460 |
68 | templates => [ |
06afcdbc |
69 | { |
06afcdbc |
70 | template => 'text_plain/test.tt', |
71 | content_type => 'text/plain', |
72 | }, |
73 | { |
74 | view => 'TT', |
75 | template => 'text_html/test.tt', |
76 | content_type => 'text/html', |
77 | }, |
78 | ], |
82300460 |
79 | }; |
80 | |
81 | $c->forward('TestApp::View::Email::Template'); |
82 | |
83 | if ( scalar( @{ $c->error } ) ) { |
84 | $c->res->status(500); |
85 | $c->res->body('Template Email Failed'); |
86 | } else { |
87 | $c->res->body('Template Email Ok'); |
c0eeefdf |
88 | } |
89 | } |
90 | |
91 | sub template_email_single : Global('template_email_single') { |
92 | my ($self, $c, @args) = @_; |
93 | |
94 | $c->stash->{time} = $c->req->params->{time} || time; |
95 | |
96 | $c->stash->{email} = { |
97 | to => 'test-email@example.com', |
98 | from => 'no-reply@example.com', |
99 | subject => 'Just a test', |
100 | content_type => 'multipart/alternative', |
101 | templates => { |
102 | view => 'TT', |
103 | template => 'text_html/test.tt', |
104 | content_type => 'text/html', |
105 | }, |
106 | |
107 | }; |
108 | |
109 | $c->forward('TestApp::View::Email::Template'); |
110 | |
111 | if ( scalar( @{ $c->error } ) ) { |
112 | $c->res->status(500); |
113 | $c->res->body('Template Email Failed'); |
114 | } else { |
115 | $c->res->body('Template Email Ok'); |
82300460 |
116 | } |
117 | } |
118 | |
beda8c31 |
119 | sub template_email_utf8 : Global('template_email_utf8') { |
120 | my ($self, $c, @args) = @_; |
121 | |
122 | $c->stash->{time} = $c->req->params->{time} || time; |
123 | |
124 | $c->stash->{chars} = decode('utf-8', "✔ ✈ ✉"); |
125 | |
126 | $c->stash->{email} = { |
127 | to => 'test-email@example.com', |
128 | from => 'no-reply@example.com', |
129 | subject => 'Just a test', |
130 | content_type => 'multipart/alternative', |
131 | templates => [ |
132 | { |
133 | template => 'text_plain/test.tt', |
134 | content_type => 'text/plain', |
135 | charset => 'utf-8', |
136 | encoding => 'quoted-printable', |
137 | }, |
138 | { |
139 | view => 'TT', |
140 | template => 'text_html/test_utf8.tt', |
141 | content_type => 'text/html', |
142 | charset => 'utf-8', |
143 | encoding => 'quoted-printable', |
144 | }, |
145 | ], |
146 | }; |
147 | |
148 | $c->forward('TestApp::View::Email::Template'); |
149 | |
150 | if ( scalar( @{ $c->error } ) ) { |
151 | $c->res->status(500); |
152 | $c->res->body('Template Email Failed'); |
153 | } else { |
154 | $c->res->body('Template Email Ok'); |
155 | } |
156 | } |
157 | |
158 | |
159 | |
8b10ee55 |
160 | sub template_email_app_config : Global('template_email_app_config') { |
161 | my ($self, $c, @args) = @_; |
162 | |
163 | $c->stash->{time} = $c->req->params->{time} || time; |
164 | |
165 | $c->stash->{template_email} = { |
166 | to => 'test-email@example.com', |
167 | from => 'no-reply@example.com', |
168 | subject => 'Just a test', |
8b10ee55 |
169 | templates => [ |
06afcdbc |
170 | { |
171 | template => 'text_plain/test.tt', |
172 | content_type => 'text/plain', |
173 | }, |
174 | { |
ea115f9b |
175 | view => 'TT', |
06afcdbc |
176 | template => 'text_html/test.tt', |
177 | content_type => 'text/html', |
178 | }, |
179 | ], |
8b10ee55 |
180 | }; |
181 | |
182 | $c->forward('TestApp::View::Email::Template::AppConfig'); |
183 | |
184 | if ( scalar( @{ $c->error } ) ) { |
185 | $c->res->status(500); |
186 | $c->res->body('Template Email Failed'); |
187 | } else { |
188 | $c->res->body('Template Email Ok'); |
189 | } |
190 | } |
191 | |
192 | sub mason_email : Global('mason_email') { |
193 | my ($self, $c, @args) = @_; |
194 | |
195 | $c->stash->{time} = $c->req->params->{time} || time; |
196 | |
197 | $c->stash->{email} = { |
198 | to => 'test-email@example.com', |
199 | from => 'no-reply@example.com', |
200 | subject => 'Just a test', |
8b10ee55 |
201 | templates => [ |
06afcdbc |
202 | { |
1e331578 |
203 | view => 'Mason', |
204 | template => 'text_plain/test.m', |
06afcdbc |
205 | content_type => 'text/plain', |
206 | }, |
207 | { |
ea115f9b |
208 | view => 'Mason', |
c649c40e |
209 | template => 'text_html/test.m', |
06afcdbc |
210 | content_type => 'text/html', |
211 | }, |
212 | ], |
8b10ee55 |
213 | }; |
214 | |
215 | $c->forward('TestApp::View::Email::Template'); |
216 | |
217 | if ( scalar( @{ $c->error } ) ) { |
218 | $c->res->status(500); |
219 | $c->res->body('Mason Email Failed'); |
220 | } else { |
221 | $c->res->body('Mason Email Ok'); |
222 | } |
223 | } |
224 | |
225 | |
82300460 |
226 | 1; |