#!/opt/perl/bin/perl -w use strict; use Encode qw/encode/; binmode STDIN, ":utf8"; open(SENDMAIL, "|/usr/sbin/sendmail @ARGV"); binmode SENDMAIL, ":utf8"; while () { chomp; length or last; print SENDMAIL (/=\?|\?=/ ? $_ : encode('MIME-Q', $_)) . "\n"; } print SENDMAIL <<"EOF"; MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EOF while () { print SENDMAIL; } close(SENDMAIL); .