Index: t/08encoding.t
===================================================================
--- t/08encoding.t (Revision 0)
+++ t/08encoding.t (Revision 0)
@@ -0,0 +1,27 @@
+use strict;
+use warnings;
+
+BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Print' }
+use Test::More;
+use Test::Warn;
+
+use Test::Requires {
+ 'Catalyst::View::TT' => '0.31',
+};
+use Email::Sender::Simple;
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use_ok('Catalyst::Test', 'TestApp');
+
+my $response;
+my $time = time;
+
+# Testk without wide chars
+warning_is { $response = request("/template_email?time=$time") } [],"Without wide chars?" ;
+
+# Test with unicode chars
+warning_is { $response = request("/template_email_utf8?time=$time") } [],"With wide chars" ;
+
+
+done_testing();
Index: t/root/text_html/test_utf8.tt
===================================================================
--- t/root/text_html/test_utf8.tt (Revision 0)
+++ t/root/text_html/test_utf8.tt (Revision 0)
@@ -0,0 +1,7 @@
+<html>
+ <body>
+ <h1>Look at my style</h1>
+ <p>I was sent to <em>[% $stash_key.to %]</em> on [% time %] with some unicode characters â â â inline and some in the stash [% chars %]</p>
+ </body>
+</html>
+
Index: t/lib/TestApp/Controller/Root.pm
===================================================================
--- t/lib/TestApp/Controller/Root.pm (Revision 13873)
+++ t/lib/TestApp/Controller/Root.pm (Arbeitskopie)
@@ -3,6 +3,8 @@
use base qw(Catalyst::Controller);
+use Encode;
+
sub default : Private {
my ( $self, $c ) = @_;
@@ -86,6 +88,47 @@
}
}
+sub template_email_utf8 : Global('template_email_utf8') {
+ my ($self, $c, @args) = @_;
+
+ $c->stash->{time} = $c->req->params->{time} || time;
+
+ $c->stash->{chars} = decode('utf-8', "â â â");
+
+ $c->stash->{email} = {
+ to => 'test-email@example.com',
+ from => 'no-reply@example.com',
+ subject => 'Just a test',
+ content_type => 'multipart/alternative',
+ templates => [
+ {
+ template => 'text_plain/test.tt',
+ content_type => 'text/plain',
+ charset => 'utf-8',
+ encoding => 'quoted-printable',
+ },
+ {
+ view => 'TT',
+ template => 'text_html/test_utf8.tt',
+ content_type => 'text/html',
+ charset => 'utf-8',
+ encoding => 'quoted-printable',
+ },
+ ],
+ };
+
+ $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');
+ }
+}
+
+
+
sub template_email_app_config : Global('template_email_app_config') {
my ($self, $c, @args) = @_;
Index: lib/Catalyst/View/Email.pm
===================================================================
--- lib/Catalyst/View/Email.pm (Revision 13873)
+++ lib/Catalyst/View/Email.pm (Arbeitskopie)
@@ -280,6 +280,9 @@
$mime{attributes}->{charset} = $self->{default}->{charset};
}
+ $mime{attributes}->{encoding} = $email->{encoding}
+ if $email->{encoding};
+
my $message = $self->generate_message( $c, \%mime );
if ($message) {
@@ -307,7 +310,8 @@
my ( $self, $c, $attrs ) = @_;
my $default_content_type = $self->default->{content_type};
- my $default_charset = $self->default->{charset};
+ my $default_charset = $self->default->{charset};
+ my $default_encoding = $self->default->{encoding};
my $e_m_attrs = {};
@@ -338,6 +342,24 @@
$e_m_attrs->{charset} = $default_charset;
}
+ if ( exists $attrs->{encoding}
+ && defined $attrs->{encoding}
+ && $attrs->{encoding} ne '' )
+ {
+ $c->log->debug(
+ 'C::V::Email uses specified encoding '
+ . $attrs->{encoding}
+ . '.' )
+ if $c->debug;
+ $e_m_attrs->{encoding} = $attrs->{encoding};
+ }
+ elsif ( defined $default_encoding && $default_encoding ne '' ) {
+ $c->log->debug(
+ "C::V::Email uses default encoding $default_encoding.")
+ if $c->debug;
+ $e_m_attrs->{encoding} = $default_encoding;
+ }
+
return $e_m_attrs;
}
Index: lib/Catalyst/View/Email/Template.pm
===================================================================
--- lib/Catalyst/View/Email/Template.pm (Revision 13873)
+++ lib/Catalyst/View/Email/Template.pm (Arbeitskopie)
@@ -167,7 +167,7 @@
my $template_prefix = $self->template_prefix;
my $default_view = $self->default->{view};
my $default_content_type = $self->default->{content_type};
- my $default_charset = $self->default->{charset};
+ my $default_charset = $self->default->{charset};
my $view;
@@ -224,10 +224,23 @@
croak $output->can('as_string') ? $output->as_string : $output;
}
- return Email::MIME->create(
- attributes => $e_m_attrs,
- body => $output,
- );
+ if ( exists $e_m_attrs->{encoding}
+ && defined $e_m_attrs->{encoding}
+ && exists $e_m_attrs->{charset}
+ && defined $e_m_attrs->{charset} ) {
+
+ return Email::MIME->create(
+ attributes => $e_m_attrs,
+ body_str => $output,
+ );
+
+ } else {
+
+ return Email::MIME->create(
+ attributes => $e_m_attrs,
+ body => $output,
+ );
+ }
}
=item process
@@ -268,7 +281,8 @@
template => $part->{template},
content_type => $part->{content_type},
charset => $part->{charset},
- }
+ encoding => $part->{encoding},
+ }
);
}
}
Index: META.yml
===================================================================
--- META.yml (Revision 13873)
+++ META.yml (Arbeitskopie)
@@ -6,10 +6,11 @@
build_requires:
ExtUtils::MakeMaker: 6.42
Test::More: 0
+ Test::Requires: 0
configure_requires:
ExtUtils::MakeMaker: 6.42
distribution_type: module
-generated_by: 'Module::Install version 0.97'
+generated_by: 'Module::Install version 1.00'
license: perl
meta-spec:
url:
http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -22,31 +23,29 @@
provides:
Catalyst::Helper::View::Email:
file: lib/Catalyst/Helper/View/Email.pm
- version: 0.28
+ version: 0.30
Catalyst::Helper::View::Email::Template:
file: lib/Catalyst/Helper/View/Email/Template.pm
- version: 0.28
+ version: 0.30
Catalyst::View::Email:
file: lib/Catalyst/View/Email.pm
- version: 0.28
+ version: 0.30
Catalyst::View::Email::Template:
file: lib/Catalyst/View/Email/Template.pm
- version: 0.28
+ version: 0.30
requires:
Authen::SASL: 2.13
Catalyst: 5.7
- Catalyst::View::Mason: 0.18
- Catalyst::View::TT: 0.31
Email::MIME: 1.859
Email::MIME::Creator: 1.455
Email::Sender::Simple: 0.100110
MIME::Base64: 3.08
Moose: 0.93
- Test::More: 0
+ Test::More: 0.88
parent: 0.223
resources:
IRC: irc://irc.perl.org/#catalyst
MailingList:
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
license:
http://dev.perl.org/licenses/
repository:
http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-View-Email/
-version: 0.28
+version: 0.30