*** omail.pl.orig Sat Nov 18 23:52:50 2000 --- omail.pl Thu Nov 30 19:23:11 2000 *************** *** 1134,1139 **** --- 1134,1140 ---- $body = $message{"body"} || ''; + $body = Jcode->new($body)->euc if($lang eq 'ja'); $body =~ s//>/g; $body =~ s/\n/
\n/g; *************** *** 1307,1312 **** --- 1308,1316 ---- if (($attnumber == 0) && (${$message{attachment}[$attnumber]}{contenttype} =~ /^text\/plain$/i)) { print hr(); + ${$message{attachment}[$attnumber]}{contents} = Jcode->new( + ${$message{attachment}[$attnumber]}{contents} )->euc + if($lang eq 'ja'); ${$message{attachment}[$attnumber]}{contents} =~ s//>/g; ${$message{attachment}[$attnumber]}{contents} =~ s/\n/
\n/g; *************** *** 1564,1570 **** if (($composetype eq "reply") || ($composetype eq "replyall")) { $subject = $message{"subject"} || ''; $subject = "Re: " . $message{"subject"} unless ($message{"subject"} =~ /^re:/i); - #koj@syon.co.jp $message{references} = '' if($message{references} eq 'N/A'); $references = " $message{references} <$message{messageid_header}>"; $inreplyto = " <$message{messageid_header}>"; --- 1569,1574 ---- *************** *** 1663,1669 **** print hidden(-name=>'folder', -default=>$folder, -override=>'1'); - # koj@syon.co.jp print hidden(-name=>'references', -default=>$references, -override=>'1'); --- 1667,1672 ---- *************** *** 1840,1859 **** $attname =~ s/^.*\///; $attname =~ s/^.*://; ! $header_from = "From: $realname <$from>\n"; ! $header_subject = "Subject: $subject\n"; if ($lang eq 'ja') { ! $header_from = &mime_unstructured_header($header_from); ! $header_subject = &mime_unstructured_header($header_subject); $body = &convert2jis($body); } open (SENDMAIL, "|" . $sendmail . " -oem -oi -F '$realname' -f '$from' -t 1>&2") or omailerror("Can't run $sendmail!"); # print SENDMAIL "From: $realname <$from>\n"; # $messagecontents .= "From: $realname <$from>\n"; ! print SENDMAIL $header_from; ! $messagecontents .= $header_from; $messagecontents .= "Date: " . localtime() . "\n"; print SENDMAIL "To: $to\n"; $messagecontents .= "To: $to\n"; --- 1843,1863 ---- $attname =~ s/^.*\///; $attname =~ s/^.*://; ! $header_from = "From: $realname <$from>"; ! $header_subject = "Subject: $subject"; if ($lang eq 'ja') { ! $to = Jcode->new($to)->mime_encode; ! $header_from = Jcode->new($header_from)->mime_encode; ! $header_subject = Jcode->new($header_subject)->mime_encode; $body = &convert2jis($body); } open (SENDMAIL, "|" . $sendmail . " -oem -oi -F '$realname' -f '$from' -t 1>&2") or omailerror("Can't run $sendmail!"); # print SENDMAIL "From: $realname <$from>\n"; # $messagecontents .= "From: $realname <$from>\n"; ! print SENDMAIL "$header_from\n"; ! $messagecontents .= "$header_from\n"; $messagecontents .= "Date: " . localtime() . "\n"; print SENDMAIL "To: $to\n"; $messagecontents .= "To: $to\n"; *************** *** 1865,1873 **** $messagecontents .= "Reply-to: $replyto\n" if $replyto; # print SENDMAIL "Subject: $subject\n"; # $messagecontents .= "Subject: $subject\n"; ! print SENDMAIL $header_subject; ! $messagecontents .= $header_subject; ! # koj@syon.co.jp print SENDMAIL "References: $references\n"; $messagecontents .= "References: $references\n"; print SENDMAIL "In-Reply-To: $inreplyto\n"; --- 1869,1876 ---- $messagecontents .= "Reply-to: $replyto\n" if $replyto; # print SENDMAIL "Subject: $subject\n"; # $messagecontents .= "Subject: $subject\n"; ! print SENDMAIL "$header_subject\n"; ! $messagecontents .= "$header_subject\n"; print SENDMAIL "References: $references\n"; $messagecontents .= "References: $references\n"; print SENDMAIL "In-Reply-To: $inreplyto\n"; *************** *** 1878,1890 **** $messagecontents .= "X-IPAddress: $ENV{REMOTE_ADDR}\n"; print SENDMAIL "X-Sender: $user\@$domainname\n"; $messagecontents .= "X-Sender: $user\@$domainname\n"; - # add 2000/10/03 koj - if($TXT{'charset'} ne '') { - print SENDMAIL "Content-Type: text/plain; charset=$TXT{'charset'}\n"; - $messagecontents .= "Content-Type: text/plain; charset=$TXT{'charset'}\n"; - print SENDMAIL "Content-Transfer-Encoding: 7bit\n"; - $messagecontents .= "Content-Transfer-Encoding: 7bit\n"; - } if ($attachment) { no strict 'refs'; --- 1881,1886 ---- *************** *** 1904,1911 **** $messagecontents .= "This is a multi-part message in MIME format.\n\n"; print SENDMAIL "--$boundary\n"; $messagecontents .= "--$boundary\n"; ! print SENDMAIL "Content-Type: text/plain; charset=US-ASCII\n\n"; ! $messagecontents .= "Content-Type: text/plain; charset=US-ASCII\n\n"; print SENDMAIL $body; $messagecontents .= $body; print SENDMAIL "\n\n--$boundary\n"; --- 1900,1909 ---- $messagecontents .= "This is a multi-part message in MIME format.\n\n"; print SENDMAIL "--$boundary\n"; $messagecontents .= "--$boundary\n"; ! print SENDMAIL "Content-Type: text/plain; charset=$TXT{'charset'}\n"; ! $messagecontents .= "Content-Type: text/plain; charset=$TXT{'charset'}\n"; ! print SENDMAIL "Content-Transfer-Encoding: 7bit\n\n"; ! $messagecontents .= "Content-Transfer-Encoding: 7bit\n\n"; print SENDMAIL $body; $messagecontents .= $body; print SENDMAIL "\n\n--$boundary\n"; *************** *** 1918,1923 **** --- 1916,1925 ---- print SENDMAIL "$attcontents\n--$boundary--"; $messagecontents .= "$attcontents\n--$boundary--"; } else { + print SENDMAIL "Content-Type: text/plain; charset=$TXT{'charset'}\n"; + $messagecontents .= "Content-Type: text/plain; charset=$TXT{'charset'}\n"; + print SENDMAIL "Content-Transfer-Encoding: 7bit\n"; + $messagecontents .= "Content-Transfer-Encoding: 7bit\n"; print SENDMAIL "\n$body\n"; $messagecontents .= "\n$body\n"; } *************** *** 2902,2908 **** sub convert2jis { my $str = shift; ! $str = &Jcode::convert(\$str, 'jis', Jcode::getcode(\$str), "z"); return $str; } --- 2904,2911 ---- sub convert2jis { my $str = shift; ! $str = Jcode->new($str)->iso_2022_jp; ! # $str = &Jcode::convert(\$str, 'jis', Jcode::getcode(\$str), "z"); return $str; } *************** *** 3153,3159 **** $headerprinted = 1; if (!$TXT{'charset'}) { $TXT{'charset'} = "iso-8859-1"; } ! if (!$TXT{'charset_http'}) { $TXT{'charset_http'} = "iso-8859-1"; } #koj my $charset_http =''; $charset_http = $TXT{'charset_http'} ? $TXT{'charset_http'}:$TXT{'charset'}; --- 3156,3162 ---- $headerprinted = 1; if (!$TXT{'charset'}) { $TXT{'charset'} = "iso-8859-1"; } ! if (!$TXT{'charset_http'}) { $TXT{'charset_http'} = "iso-8859-1"; } my $charset_http =''; $charset_http = $TXT{'charset_http'} ? $TXT{'charset_http'}:$TXT{'charset'}; *************** *** 3232,3322 ****

"; } ################# END PRINTFOOTER ######################### - - ################# MIME HEADER ENCODING #################### - # Come from http://www.din.or.jp/~ohzaki/perl.htm - # by Ohzaki Hiroki - # - if ($lang eq 'ja') { - use MIME::Base64; - } - - sub add_encoded_word { - my($str, $line) = @_; - my $ascii = '[\x00-\x7F]'; - my $twoBytes = '[\x8E\xA1-\xFE][\xA1-\xFE]'; - my $threeBytes = '\x8F[\xA1-\xFE][\xA1-\xFE]'; - my $result; - - while (length($str)) { - my $target = $str; - $str = ''; - if (length($line) + 22 + - ($target =~ /^(?:$twoBytes|$threeBytes)/o) * 8 > 76) { - $line =~ s/[ \t\n\r]*$/\x0D\x0A/; - $result .= $line; - $line = ' '; - } - while (1) { - my $encoded = '=?ISO-2022-JP?B?' . - # encode_base64(Jcode::jis($target, 'euc', 'z'), '') . '?='; - encode_base64(Jcode::convert($target, 'jis', 'euc', 'z'), '') . '?='; - if (length($encoded) + length($line) > 76) { - $target =~ s/($threeBytes|$twoBytes|$ascii)$//o; - $str = $1 . $str; - } else { - $line .= $encoded; - last; - } - } - } - $result . $line; - } - - # - # MIME encoding 'unstructured header $header' - # - sub mime_unstructured_header { - my $oldheader = shift; - my $header; - my $i; - my @words; - my @wordstmp; - my $word; - - $oldheader = Jcode->new($oldheader)->euc; - $oldheader =~ s/\s+$//; - @wordstmp = split /\s+/, $oldheader; - for ($i = 0; $i < $#wordstmp; $i++) { - if ($wordstmp[$i] !~ /^[\x21-\x7E]+$/ and - $wordstmp[$i + 1] !~ /^[\x21-\x7E]+$/) { - $wordstmp[$i + 1] = "$wordstmp[$i] $wordstmp[$i + 1]"; - } else { - push(@words, $wordstmp[$i]); - } - } - push(@words, $wordstmp[-1]); - foreach $word (@words) { - if ($word =~ /^[\x21-\x7E]+$/) { - $header =~ /(?:.*\x0D\x0A)?(.*)/; - if (length($1) + length($word) > 76) { - $header .= "\x0D\x0A $word"; - } else { - $header .= $word; - } - } else { - $header = add_encoded_word($word, $header); - } - $header =~ /(?:.*\x0D\x0A)?(.*)/; - if (length($1) == 76) { - $header .= "\x0D\x0A "; - } else { - $header .= ' '; - } - } - $header =~ s/(?:\x0D\x0A)? $/\x0D\x0A/; - $header; - } - - ############### END MIME HEADER ENCODING #################### --- 3235,3238 ----