1 package # Hide from PAUSE
2 TestApp::Controller::Root;
4 use base qw(Catalyst::Controller);
8 sub default : Private {
11 $c->res->body(qq{Nothing Here});
14 sub email : Global('email') {
15 my ($self, $c, @args) = @_;
17 my $time = $c->req->params->{time} || time;
19 $c->stash->{email} = {
20 to => 'test-email@example.com',
21 from => 'no-reply@example.com',
22 subject => 'Email Test',
23 body => "Email Sent at: $time"
26 $c->forward('TestApp::View::Email');
28 if ( scalar( @{ $c->error } ) ) {
30 $c->res->body('Email Failed');
32 $c->res->body('Plain Email Ok');
36 sub email_app_config : Global('email_app_config') {
37 my ($self, $c, @args) = @_;
39 my $time = $c->req->params->{time} || time;
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"
48 $c->forward('TestApp::View::Email::AppConfig');
50 if ( scalar( @{ $c->error } ) ) {
52 $c->res->body('Email Failed');
54 $c->res->body('Plain Email Ok');
58 sub template_email : Global('template_email') {
59 my ($self, $c, @args) = @_;
61 $c->stash->{time} = $c->req->params->{time} || time;
63 $c->stash->{email} = {
64 to => 'test-email@example.com',
65 from => 'no-reply@example.com',
66 subject => 'Just a test',
67 content_type => 'multipart/alternative',
70 template => 'text_plain/test.tt',
71 content_type => 'text/plain',
75 template => 'text_html/test.tt',
76 content_type => 'text/html',
81 $c->forward('TestApp::View::Email::Template');
83 if ( scalar( @{ $c->error } ) ) {
85 $c->res->body('Template Email Failed');
87 $c->res->body('Template Email Ok');
91 sub template_email_utf8 : Global('template_email_utf8') {
92 my ($self, $c, @args) = @_;
94 $c->stash->{time} = $c->req->params->{time} || time;
96 $c->stash->{chars} = decode('utf-8', "✔ ✈ ✉");
98 $c->stash->{email} = {
99 to => 'test-email@example.com',
100 from => 'no-reply@example.com',
101 subject => 'Just a test',
102 content_type => 'multipart/alternative',
105 template => 'text_plain/test.tt',
106 content_type => 'text/plain',
108 encoding => 'quoted-printable',
112 template => 'text_html/test_utf8.tt',
113 content_type => 'text/html',
115 encoding => 'quoted-printable',
120 $c->forward('TestApp::View::Email::Template');
122 if ( scalar( @{ $c->error } ) ) {
123 $c->res->status(500);
124 $c->res->body('Template Email Failed');
126 $c->res->body('Template Email Ok');
132 sub template_email_app_config : Global('template_email_app_config') {
133 my ($self, $c, @args) = @_;
135 $c->stash->{time} = $c->req->params->{time} || time;
137 $c->stash->{template_email} = {
138 to => 'test-email@example.com',
139 from => 'no-reply@example.com',
140 subject => 'Just a test',
143 template => 'text_plain/test.tt',
144 content_type => 'text/plain',
148 template => 'text_html/test.tt',
149 content_type => 'text/html',
154 $c->forward('TestApp::View::Email::Template::AppConfig');
156 if ( scalar( @{ $c->error } ) ) {
157 $c->res->status(500);
158 $c->res->body('Template Email Failed');
160 $c->res->body('Template Email Ok');
164 sub mason_email : Global('mason_email') {
165 my ($self, $c, @args) = @_;
167 $c->stash->{time} = $c->req->params->{time} || time;
169 $c->stash->{email} = {
170 to => 'test-email@example.com',
171 from => 'no-reply@example.com',
172 subject => 'Just a test',
176 template => 'text_plain/test.m',
177 content_type => 'text/plain',
181 template => 'text_html/test.m',
182 content_type => 'text/html',
187 $c->forward('TestApp::View::Email::Template');
189 if ( scalar( @{ $c->error } ) ) {
190 $c->res->status(500);
191 $c->res->body('Mason Email Failed');
193 $c->res->body('Mason Email Ok');