Tadashi Okoshi
slash****@users*****
2006年 5月 8日 (月) 21:47:12 JST
Index: affelio/lib/Affelio/NetLib/Email.pm
diff -u affelio/lib/Affelio/NetLib/Email.pm:1.12 affelio/lib/Affelio/NetLib/Email.pm:1.13
--- affelio/lib/Affelio/NetLib/Email.pm:1.12 Tue Mar 7 23:39:11 2006
+++ affelio/lib/Affelio/NetLib/Email.pm Mon May 8 21:47:12 2006
@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# $Id: Email.pm,v 1.12 2006/03/07 14:39:11 slash5234 Exp $
+# $Id: Email.pm,v 1.13 2006/05/08 12:47:12 slash5234 Exp $
package Affelio::NetLib::Email;
{
@@ -22,6 +22,8 @@
use lib("../../../extlib");
use Exporter;
use Jcode;
+ use charnames qw/:full/;
+ use Encode;
use MIME::Base64;
use lib("../../../lib");
use Affelio::misc::Debug;
@@ -40,21 +42,40 @@
my $body = shift;
my $filename = shift;
my $attach = shift;
+ my $encoding = shift; #ISO-2022-JP
+
+ if($encoding eq ""){
+ $encoding = "utf-8";
+ }
+
my $boundary = "-*-*-*-*-*-*-*-*-Boundary_" . time . "_" . $$;
my $eol = "";
+
+ #####
+ #Subject
+ if($encoding ne "utf-8"){
+ Encode::from_to($subject, "utf8", $encoding);
+ }
my $subject_b = MIME::Base64::encode_base64($subject, $eol);
- $subject_b = "=?utf-8?B?" . $subject_b . "?=";
+ $subject_b = "=?$encoding?B?" . $subject_b . "?=";
+
my $headers = "From: $from_name <$from_addr>\nMIME-Version: 1.0\n";
if ($attach ne "" && $filename ne ""){
$filename = MIME::Base64::encode_base64($filename, $eol);
- $filename = "=?utf-8?B?" . $filename . "?=";
+ $filename = "=?$encoding?B?" . $filename . "?=";
$attach = MIME::Base64::encode_base64($attach);
$headers .= "Content-Type: Multipart/Mixed; boundary=\"$boundary\"\n";
}else{
- $headers .= "Content-Type: text/plain; charset=utf-8\n";
+ $headers .= "Content-Type: text/plain; charset=$encoding\n";
}
$headers .= "Content-Transfer-Encoding: base64\n";
+
+ #####
+ #Body
+ if($encoding ne "utf-8"){
+ Encode::from_to($body, "utf8", $encoding);
+ }
my $body_b = MIME::Base64::encode_base64($body);
###########################################
@@ -66,7 +87,7 @@
print MAIL "Subject: $subject_b\n\n";
if ($attach ne "" && $filename ne ""){
print MAIL "--$boundary\n";
- print MAIL "Content-Type: text/plain; charset=utf-8\n";
+ print MAIL "Content-Type: text/plain; charset=$encoding\n";
print MAIL "Content-Transfer-Encoding: base64\n";
print MAIL "\n"
}