CentOS 5.x の logwatch からのメールに日本語が含まれている場合に、content-type が決め打ちなのでメーラーで文字化けする件の対応。
syslog などが UTF-8 な前提で、logwatch は以下のバージョンです。
# logwatch --version Logwatch 7.3 (released 03/24/06) # rpm -q logwatch logwatch-7.3-6.el5
まず、/usr/sbin/logwatch は /usr/share/logwatch/scripts/logwatch.pl にシンボリックリンクされているので、
編集対象は logwatch.pl です。
以下にパッチ。
iso-8859-1 を utf-8 にしただけです。
# diff -wc logwatch.pl.orig logwatch.pl
*** logwatch.pl.orig 2008-05-25 01:42:04.000000000 +0900
--- logwatch.pl 2009-05-29 00:25:35.000000000 +0900
***************
*** 1019,1027 ****
$out_mime .= "Content-Transfer-Encoding: 7bit\n";
}
if ( $outtype_html ) {
! $out_mime .= "Content-Type: text/html; charset=\"iso-8859-1\"\n\n";
} else {
! $out_mime .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n\n";
}
if (($Config{'splithosts'} eq 1) && ($Config{'multiemail'} eq 0)) {
--- 1019,1027 ----
$out_mime .= "Content-Transfer-Encoding: 7bit\n";
}
if ( $outtype_html ) {
! $out_mime .= "Content-Type: text/html; charset=\"utf-8\"\n\n";
} else {
! $out_mime .= "Content-Type: text/plain; charset=\"utf-8\"\n\n";
}
if (($Config{'splithosts'} eq 1) && ($Config{'multiemail'} eq 0)) {
#
実際にはこれで動くが本当は Content-Transfer-Encoding: 7bit も嘘なので base64 にするか quoted-printable にして、本文もそれに対応さる必要があることは SE としては認識しておかなければならない。
仕事ではちゃんとすること!

コメント