[Codestriker-commits] CVS update: codestriker/lib/Codestriker/TopicListeners Email.pm
Brought to you by:
sits
|
From: <si...@us...> - 2006-05-22 11:37:23
|
User: sits
Date: 06/05/22 04:34:17
Modified: bin codestriker.pl.base install.pl
lib/Codestriker/TopicListeners Email.pm
Log:
Make email code handle unicode data correctly
Index: codestriker.pl.base
===================================================================
RCS file: /cvsroot/codestriker/codestriker/bin/codestriker.pl.base,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- codestriker.pl.base 19 May 2006 00:40:15 -0000 1.20
+++ codestriker.pl.base 22 May 2006 11:34:16 -0000 1.21
@@ -81,7 +81,7 @@
}
# Make sure the STDOUT encoding is set to UTF8.
-binmode STDOUT, ':utf8';
+# binmode STDOUT, ':utf8';
# Prototypes of subroutines used in this module.
sub main();
Index: install.pl
===================================================================
RCS file: /cvsroot/codestriker/codestriker/bin/install.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- install.pl 18 Apr 2006 10:45:40 -0000 1.3
+++ install.pl 22 May 2006 11:34:16 -0000 1.4
@@ -73,6 +73,10 @@
name => 'Net::SMTP',
version => '0'
},
+ {
+ name => 'MIME::QuotedPrint',
+ version => '0'
+ },
{
name => 'DBI',
version => '1.13'
Index: Email.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/TopicListeners/Email.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Email.pm 16 Jan 2006 10:49:23 -0000 1.17
+++ Email.pm 22 May 2006 11:34:16 -0000 1.18
@@ -12,10 +12,12 @@
package Codestriker::TopicListeners::Email;
-use Codestriker::TopicListeners::TopicListener;
+use MIME::QuotedPrint qw(encode_qp);
use Net::SMTP;
use Sys::Hostname;
+use Codestriker::TopicListeners::TopicListener;
+
# Separator to use in email.
my $EMAIL_HR = "--------------------------------------------------------------";
# If true, just ignore all email requests.
@@ -477,11 +479,23 @@
$smtp->datasend("In-Reply-To: $message_id\n");
}
- $smtp->datasend("Subject: $subject\n");
+ # Make sure the subject is appropriately encoded to handle UTF-8
+ # characters.
+ # TODO: use Encode qw(encode);
+ # TODO: should be encode_qp(encode("UTF-8", $subject), '')
+ $smtp->datasend('Subject: =?UTF-8?Q?' . encode_qp($subject, '') .
+ '?=' . "\n");
+
+ # Set the content type to be text/plain with UTF8 encoding, to handle
+ # unicode characters.
+ $smtp->datasend("Content-Type: text/plain; charset=\"utf-8\"\n");
+ $smtp->datasend("Content-Transfer-Encoding: quoted-printable\n");
# Insert a blank line for the body.
$smtp->datasend("\n");
- $smtp->datasend($body);
+
+ # TODO: should be $smtp->datasend(encode_qp(encode("UTF-8", $body)));
+ $smtp->datasend(encode_qp($body));
$smtp->dataend();
$smtp->ok() || return "Couldn't send email $!, " . smtp->message();
|