--- /dev/null
+use strict;
+use warnings;
+use Test::More tests => 5;
+
+use Email::Send::Test;
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use_ok('Catalyst::Test', 'TestApp');
+
+my $response;
+my $time = time;
+ok( ($response = request("/email?time=$time"))->is_success, 'request ok');
+
+my @emails = Email::Send::Test->emails;
+
+is(@emails, 1, "got emails");
+isa_ok( $emails[0], 'Email::MIME', 'email is ok' );
+like($emails[0]->body, qr/$time/, 'Got our email');
--- /dev/null
+use strict;
+use warnings;
+use Test::More tests => 5;
+
+use Email::Send::Test;
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use_ok('Catalyst::Test', 'TestApp');
+
+my $response;
+my $time = time;
+ok( ( $response = request("/template_email?time=$time"))->is_success,
+ 'request ok' );
+like( $response->content, qr/Template Email Ok/, 'controller says ok' );
+my @emails = Email::Send::Test->emails;
+
+cmp_ok(@emails, '==', 1, 'got emails');
+isa_ok( $emails[0], 'Email::MIME', 'email is ok' );
+my @parts = $emails[0]->parts;
+cmp_ok(@parts, '==', 2, 'got parts');
+
+is($parts[0]->content_type, 'text/plain; charset="us-ascii"', 'text/plain ok');
+like($parts[0]->body, qr/jshirley\@picturetrail.com on $time/, 'got content back');
+is($parts[1]->content_type, 'text/html; charset="us-ascii"', 'text/html ok');
+like($parts[1]->body, qr{<em>jshirley\@picturetrail.com</em> on $time}, 'got content back');
+#like($emails[0]->body, qr/$time/, 'Got our email');
+
--- /dev/null
+package # Hide from PAUSE
+ TestApp;
+
+use Catalyst;
+use FindBin;
+
+TestApp->config(
+ root => "$FindBin::Bin/root",
+ default_view => 'TT'
+);
+
+TestApp->setup;
+
+1;
--- /dev/null
+package # Hide from PAUSE
+ TestApp::Controller::Root;
+
+use base qw(Catalyst::Controller);
+
+sub default : Private {
+ my ( $self, $c ) = @_;
+
+ $c->res->body(qq{Nothing Here});
+}
+
+sub email : Global('email') {
+ my ($self, $c, @args) = @_;
+
+ my $time = $c->req->params->{time} || time;
+
+ $c->stash->{email} = {
+ to => 'jshirley@picturetrail.com',
+ from => 'no-reply@toeat.com',
+ subject => 'Email Test',
+ body => "Email Sent at: $time"
+ };
+
+ $c->forward('TestApp::View::Email');
+
+ if ( scalar( @{ $c->error } ) ) {
+ $c->res->status(500);
+ $c->res->body('Email Failed');
+ } else {
+ $c->res->body('Plain Email Ok');
+ }
+}
+
+sub template_email : Global('template_email') {
+ my ($self, $c, @args) = @_;
+
+ $c->stash->{time} = $c->req->params->{time} || time;
+
+ $c->stash->{email} = {
+ to => 'jshirley@picturetrail.com',
+ from => 'no-reply@toeat.com',
+ subject => 'Just a test',
+ content_type => 'multipart/alternative',
+ templates => [
+ qw{text_plain/test.tt},
+ qw{text_html/test.tt}
+ ]
+ };
+
+ $c->forward('TestApp::View::Email::Template');
+
+ if ( scalar( @{ $c->error } ) ) {
+ $c->res->status(500);
+ $c->res->body('Template Email Failed');
+ } else {
+ $c->res->body('Template Email Ok');
+ }
+}
+
+1;
--- /dev/null
+package # Hide from PAUSE
+ TestApp::View::Email;
+
+use Email::Send::Test;
+
+use base 'Catalyst::View::Email';
+
+__PACKAGE__->config(
+ sender => {
+ method => 'Test'
+ },
+);
+
+1;
--- /dev/null
+package # Hide me
+ TestApp::View::Email::Template;
+
+use strict;
+use base 'Catalyst::View::Email::Template';
+
+__PACKAGE__->config(
+ sender => {
+ method => 'Test'
+ },
+ stash_key => 'email',
+ template_prefix => ''
+);
+
+1;
--- /dev/null
+package # Hide me.
+ TestApp::View::TT;
+
+use strict;
+use base 'Catalyst::View::TT';
+
+1;
--- /dev/null
+<html>
+ <body>
+ <h1>Look at my style</h1>
+ <p>I was sent to <em>[% email.to %]</em> on [% time %]</p>
+ </body>
+</html>
+
--- /dev/null
+I am plain text. I have no style.
+
+I was sent to [% email.to %] on [% time %]