Jul 27
作者: 肖建彬 | 可以转载, 转载时务必以超链接形式标明文章原始出处和作者信息及版权声明
网址:http://www.xiaojb.com/archives/mailtech/webmail_extmail.shtml
网址:http://www.xiaojb.com/archives/mailtech/webmail_extmail.shtml
extmail是强哥开发的,强哥很强,大家有目共睹。spamloker/extmail等软件不断,为广大的mailer提供了很多的方便。
安装extmail后,发现中文显示正常,但是回复邮件的时候就出现了问题,没有将非UTF-8的邮件转换为UTF-8,我改了一下Compose.pm,可以用了,等强哥上线后交流一下。
修改的部分如下:
下载: extmail.diff
--- extmail-0.24-pre8/libs/Ext/App/Compose.pm 2006-07-09 09:21:30.000000000 +0800
+++ extmail/libs/Ext/App/Compose.pm 2006-07-27 18:40:59.000000000 +0800
@@ -402,15 +402,15 @@
my $hdr = $parts->{head}{hash};
my $date = hdr_get_hash('Date', %$hdr);
- my $from = decode_words(hdr_get_hash('From', %$hdr));
- my $replyto = decode_words(hdr_get_hash('Reply-To', %$hdr));
- my $return = decode_words(hdr_get_hash('Return-Path', %$hdr));
+ my $from = decode_words_ncr(hdr_get_hash('From', %$hdr));
+ my $replyto = decode_words_ncr(hdr_get_hash('Reply-To', %$hdr));
+ my $return = decode_words_ncr(hdr_get_hash('Return-Path', %$hdr));
my ($to, $cc, $bcc) = (
- decode_words(hdr_get_hash('To', %$hdr)),
- decode_words(hdr_get_hash('Cc', %$hdr)),
- decode_words(hdr_get_hash('Bcc', %$hdr))
+ decode_words_ncr(hdr_get_hash('To', %$hdr)),
+ decode_words_ncr(hdr_get_hash('Cc', %$hdr)),
+ decode_words_ncr(hdr_get_hash('Bcc', %$hdr))
);
- my $subj = decode_words(hdr_get_hash('Subject', %$hdr));
+ my $subj = decode_words_ncr(hdr_get_hash('Subject', %$hdr));
my $pftype = $usercfg->{compose_html} ? 'text/html' : 'text/plain';
my $bodyref = _getbody($parts, $file, $pftype);
@@ -426,6 +426,8 @@
my $ctype = hdr_get_hash('Content-Type', %{$part0->{phead}}) || 'text/plain';
my $text = $bodyref->{body};# the body text!
+ my $charset = lc($part0->{phead}{charset});
+ $text = str2ncr($charset, $text);
my $body_is_html = 0;
$date =~ s/\s*[-+]\d+\s*.*//;
@@ -477,7 +479,7 @@
$tpl->assign(
CCSENT => $usercfg->{'ccsent'},
TO => html_fmt($replyto || $from || $return),
- SUBJECT => html_fmt('Re: '.$subj),
+ SUBJECT => 'Re: '.$subj,
BODY=>$text."\n\n". $self->get_signature($ctype),
RTE_ON => $usercfg->{'compose_html'},
);
+++ extmail/libs/Ext/App/Compose.pm 2006-07-27 18:40:59.000000000 +0800
@@ -402,15 +402,15 @@
my $hdr = $parts->{head}{hash};
my $date = hdr_get_hash('Date', %$hdr);
- my $from = decode_words(hdr_get_hash('From', %$hdr));
- my $replyto = decode_words(hdr_get_hash('Reply-To', %$hdr));
- my $return = decode_words(hdr_get_hash('Return-Path', %$hdr));
+ my $from = decode_words_ncr(hdr_get_hash('From', %$hdr));
+ my $replyto = decode_words_ncr(hdr_get_hash('Reply-To', %$hdr));
+ my $return = decode_words_ncr(hdr_get_hash('Return-Path', %$hdr));
my ($to, $cc, $bcc) = (
- decode_words(hdr_get_hash('To', %$hdr)),
- decode_words(hdr_get_hash('Cc', %$hdr)),
- decode_words(hdr_get_hash('Bcc', %$hdr))
+ decode_words_ncr(hdr_get_hash('To', %$hdr)),
+ decode_words_ncr(hdr_get_hash('Cc', %$hdr)),
+ decode_words_ncr(hdr_get_hash('Bcc', %$hdr))
);
- my $subj = decode_words(hdr_get_hash('Subject', %$hdr));
+ my $subj = decode_words_ncr(hdr_get_hash('Subject', %$hdr));
my $pftype = $usercfg->{compose_html} ? 'text/html' : 'text/plain';
my $bodyref = _getbody($parts, $file, $pftype);
@@ -426,6 +426,8 @@
my $ctype = hdr_get_hash('Content-Type', %{$part0->{phead}}) || 'text/plain';
my $text = $bodyref->{body};# the body text!
+ my $charset = lc($part0->{phead}{charset});
+ $text = str2ncr($charset, $text);
my $body_is_html = 0;
$date =~ s/\s*[-+]\d+\s*.*//;
@@ -477,7 +479,7 @@
$tpl->assign(
CCSENT => $usercfg->{'ccsent'},
TO => html_fmt($replyto || $from || $return),
- SUBJECT => html_fmt('Re: '.$subj),
+ SUBJECT => 'Re: '.$subj,
BODY=>$text."\n\n". $self->get_signature($ctype),
RTE_ON => $usercfg->{'compose_html'},
);

Recent Comments