[open-ils-commits] r19476 - in trunk/Open-ILS/src: extras perlmods/lib/OpenILS/Application/Trigger/Reactor (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Feb 18 00:44:14 EST 2011


Author: dbs
Date: 2011-02-18 00:44:11 -0500 (Fri, 18 Feb 2011)
New Revision: 19476

Modified:
   trunk/Open-ILS/src/extras/Makefile.install
   trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm
Log:
Bolster SendEmail Reactor's handling of UTF-8 content

Use the Encode module and encode_utf8() instead of utf8 and utf8::encode.
The utf8 module is meant for enabling UTF-8 content in source code.

Also, add the MIME-Version / Content-type / charset headers that
some mail user agents need to know that they're dealing with Unicode
mail.


Modified: trunk/Open-ILS/src/extras/Makefile.install
===================================================================
--- trunk/Open-ILS/src/extras/Makefile.install	2011-02-17 20:58:41 UTC (rev 19475)
+++ trunk/Open-ILS/src/extras/Makefile.install	2011-02-18 05:44:11 UTC (rev 19476)
@@ -87,6 +87,7 @@
 	libdatetime-set-perl\
 	libdbd-pg-perl\
 	libemail-send-perl\
+	libemail-simple-perl\
 	libgd-graph3d-perl\
 	liblog-log4perl-perl\
 	libmarc-record-perl\
@@ -172,6 +173,7 @@
 	perl-Business-ISBN-Data \
 	perl-DBD-Pg \
 	perl-Email-Send \
+	perl-Email-Simple \
 	perl-GDGraph3d \
 	perl-Net-SSH2 \
 	perl-OLE-Storage_Lite \

Modified: trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm	2011-02-17 20:58:41 UTC (rev 19475)
+++ trunk/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/SendEmail.pm	2011-02-18 05:44:11 UTC (rev 19476)
@@ -3,10 +3,11 @@
 use Error qw/:try/;
 use Data::Dumper;
 use Email::Send;
+use Email::Simple;
 use OpenSRF::Utils::SettingsClient;
 use OpenILS::Application::Trigger::Reactor;
 use OpenSRF::Utils::Logger qw/:logger/;
-use utf8;
+use Encode;
 $Data::Dumper::Indent = 0;
 
 use base 'OpenILS::Application::Trigger::Reactor';
@@ -24,6 +25,10 @@
 /opensrf/default/email_notify/sender_address is passed into the template as
 the 'default_sender' variable.
 
+Email is encoded in UTF-8 and the corresponding MIME-Version, Content-Type,
+and Content-Transfer-Encoding headers are set to help mail user agents
+decode the content.
+
 No default template is assumed, and all information other than the
 default_sender that the system provides is expected to be gathered by the
 Event Definition through either Environment or Parameter definitions.
@@ -39,7 +44,7 @@
     my $smtp = $conf->config_value('email_notify', 'smtp_server');
     $$env{default_sender} = $conf->config_value('email_notify', 'sender_address');
 
-    my $text = $self->run_TT($env);
+    my $text = encode_utf8($self->run_TT($env));
     return 0 if (!$text);
 
     my $sender = Email::Send->new({mailer => 'SMTP'});
@@ -48,10 +53,13 @@
     my $stat;
     my $err;
 
-    utf8::encode($text); # prevent "Wide character" errors in Email::Send
+    my $email = Email::Simple->new($text);
+    $email->header_set('MIME-Version' => '1.0');
+    $email->header_set('Content-Type' => "text/plain; charset=UTF-8");
+    $email->header_set('Content-Transfer-Encoding' => '8bit');
 
     try {
-        $stat = $sender->send($text);
+        $stat = $sender->send($email);
     } catch Error with {
         $err = $stat = shift;
         $logger->error("SendEmail Reactor: Email failed with error: $err");



More information about the open-ils-commits mailing list