[Slashdotjp-dev 547] CVS update: slashjp/Slash/Utility/System

Back to archive index

Tatsuki SUGIURA sugi****@users*****
2006年 7月 12日 (水) 21:24:22 JST


Index: slashjp/Slash/Utility/System/System.pm
diff -u slashjp/Slash/Utility/System/System.pm:1.9 slashjp/Slash/Utility/System/System.pm:1.10
--- slashjp/Slash/Utility/System/System.pm:1.9	Wed Jul 12 20:41:41 2006
+++ slashjp/Slash/Utility/System/System.pm	Wed Jul 12 21:24:22 2006
@@ -1,7 +1,7 @@
 # This code is a part of Slash, and is released under the GPL.
 # Copyright 1997-2005 by Open Source Technology Group. See README
 # and COPYING for more information, or see http://slashcode.com/.
-# $Id: System.pm,v 1.9 2006/07/12 11:41:41 sugi Exp $
+# $Id: System.pm,v 1.10 2006/07/12 12:24:22 sugi Exp $
 
 package Slash::Utility::System;
 
@@ -25,6 +25,8 @@
 =cut
 
 use strict;
+use open ":utf8";
+use open ":std";
 use Fcntl qw(:flock :seek);
 use File::Basename;
 use File::Path;
@@ -36,11 +38,12 @@
 use Slash::Utility::Environment;
 use Symbol 'gensym';
 use Time::HiRes ();
+use Encode;
 
 use base 'Exporter';
 use vars qw($VERSION @EXPORT @EXPORT_OK);
 
-($VERSION) = ' $Revision: 1.9 $ ' =~ /\$Revision:\s+([^\s]+)/;
+($VERSION) = ' $Revision: 1.10 $ ' =~ /\$Revision:\s+([^\s]+)/;
 @EXPORT	   = qw(
 	bulkEmail
 	doEmail
@@ -119,14 +122,33 @@
 		return 0;
 	}
 
+	# Character Code Conversion; target encoding must be valid name
+	# Characters not representable in the destination character set
+	# and encoding will be replaced with \x{HHHH} place-holders
+	# (s. Encode(3) perldoc, Handling Malformed Data)
+	my $b_code = $constants->{mail_charset_body} || "UTF-8";
+	my $h_code = $constants->{mail_charset_header} || "MIME-Header";
+	$content = encode( $b_code, $content, Encode::FB_PERLQQ );
+	$subject = encode( $h_code, $subject, Encode::FB_PERLQQ );
+
+	# set enverope from
+	my $sender = $constants->{mailfrom};
+	if ($constants->{bounce_address}) {
+		$sender = $constants->{bounce_address};
+		my $bounce_addr = $addr;
+		$bounce_addr =~ s/@/=/;
+		$sender =~ s/###ADDR###/$bounce_addr/;
+	}
+
 	my %data = (
+		Sender		=> $sender,
 		From		=> $constants->{mailfrom},
 		Smtp		=> $constants->{smtp_server},
 		Subject		=> $subject,
 		Message		=> $content,
 		To		=> $addr,
 		# put in vars ... ?
-		'Content-type'			=> 'text/plain; charset="us-ascii"',
+		'Content-type'			=> qq|text/plain; charset="$b_code"|,
 		'Content-transfer-encoding'	=> '8bit',
 		'Message-Id'			=> messageID(),
 	);
@@ -190,6 +212,12 @@
 
 	my @list = grep { emailValid($_) } @$addrs;
 
+	# Character Code Conversion; see comments in sendEmail()
+	my $b_code = $constants->{mail_charset_body} || "UTF-8";
+	my $h_code = $constants->{mail_charset_header} || "MIME-Header";
+	$content = encode( $b_code, $content, Encode::FB_PERLQQ );
+	$subject = encode( $h_code, $subject, Encode::FB_PERLQQ );
+
 	my $bulk = Slash::Custom::Bulkmail->new(
 		From    => $constants->{mailfrom},
 		Smtp	=> $constants->{smtp_server},
@@ -200,7 +228,7 @@
 		BAD	=> $badfile,
 		ERRFILE	=> $errfile,
 		# put in vars ... ?
-		'Content-type'			=> 'text/plain; charset="us-ascii"',
+		'Content-type'			=> qq|text/plain; charset="$b_code"|,
 		'Content-transfer-encoding'	=> '8bit',
 		'Message-Id'			=> messageID(),
 	);
@@ -515,4 +543,4 @@
 
 =head1 VERSION
 
-$Id: System.pm,v 1.9 2006/07/12 11:41:41 sugi Exp $
+$Id: System.pm,v 1.10 2006/07/12 12:24:22 sugi Exp $


Slashdotjp-dev メーリングリストの案内
Back to archive index