sendmail && UTF-8

Matthias Apitz guru at unixarea.de
Tue Mar 23 12:29:32 UTC 2010


Hello,

I want to sendout mail the following way:

	sendmail -t < filename

where the file 'filename' contains some header lines, especially To:
 Subject: and From:  and as well the body of the mail; all is in UTF-8
and I know I have to encode the header lines and says something about
the body. With Perl it goes like this:

 #!/usr/bin/perl

 use utf8;
 use Encode;

 open (MAIL, "|/usr/lib/sendmail -t");

 $x="Subject: ... with some UTF-8 chars";
 $x_for_header = Encode::encode('MIME-Q', $x);

 print MAIL "From: .......\n";
 print MAIL "To: .......\n";
 print MAIL $x_for_header."\n";
 print MAIL "Content-type: text/xml\;charset=UTF-8\n";
 print MAIL "Content-Transfer-Encoding: 8bit\n";
 print MAIL "\n";
 ... now the plain UTF-8 body follows
 close(MAIL) || warn "Error closing mail: $!";
 }

How can I encode the header lines (like the above Subject: line) not
using Perl, i.e. with plain shell tools; I've checked out metamail and
such stuff, but they don't help. Any idea? Thanks in advance

	matthias
-- 
Matthias Apitz
t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211
e <guru at unixarea.de> - w http://www.unixarea.de/
Solidarity with the imperialistic Israel? Not in my name!
¿Solidaridad con el imperialismo de Israel? ¡No en mi nombre!


More information about the freebsd-questions mailing list