Petrus de Calguarium <kwhiskerz@...> writes:
When I receive system mail, I read it on the command line with the 'mail'
program. It appears to be called
Heirloom Mail version 12.4 7/29/08.
Now, as I scroll down, I see that the system mail is sent as:
Content-Type: text/plain; charset="ANSI_X3.4-1968"
However, my system is set up to use UTF-8. Why is this charset wrong, or not
respecting my system setting? How
can I get it corrected?
Hi,
I hope this explains both logwatch mail and interactive mail.
Formatting of mail (headers and body) by logwatch script (in Perl):
less /usr/share/logwatch/scripts/logwatch.pl
...
my $report_finish = "\n ###################### Logwatch End ...
...
#Add MIME
...
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";
}
...
This is an example of my logwatch mail:
From root(a)localhost.localdomain Wed Jul 21 08:33:07 2010
Return-Path: <root(a)localhost.localdomain>
Date: Wed, 21 Jul 2010 08:33:05 +0200
To: root(a)localhost.localdomain
From: logwatch(a)localhost.localdomain
Subject: Logwatch for localhost.localdomain (Linux)
Content-Type: text/plain; charset="iso-8859-1"
Status: RO
################### Logwatch 7.3.6 (05/19/07) ####################
...
So, the logwatch formats the mail programmatically (line by line), and this
explains the arbitrary fixed string charset="iso-8859-1".
On the other hand, if I prepare mail interactively in my terminal, formatted
by the mail agent, it is subjected to that mail agent's rules.
[jb@localhost ~]$ env |grep LANG
LANG=en_US.UTF-8
$ man mail
...
sendcharsets
A comma-separated list of character set names that can be used
in Internet mail. When a message that contains characters not
representable in US-ASCII is prepared for sending, mailx tries
to convert its text to each of the given character sets in order
and uses the first appropriate one. The default is ‘utf-8’.
Character sets assigned to this variable should be ordered in
ascending complexity. That is, the list should start with e.g.
‘iso-8859-1’ for compatibility with older mail clients, might
contain some other language-specific character sets, and should
end with ‘utf-8’ to handle messages that combine texts in multi-
ple languages.
...
$ cat /etc/mail.rc
...
# Outgoing messages are sent in ISO-8859-1 if all their characters are
# representable in it, otherwise in UTF-8.
set sendcharsets=iso-8859-1,utf-8
...
[jb@localhost ~]$ mail root
Subject: test charset
A line of text.
--> Ctl-D to finish
[jb@localhost ~]$ mail
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/jb": 2 messages 2 unread
U 1 logwatch(a)localhost.l Tue Jul 27 07:35 100/2779 "Logwatch
for localhos"
U 2 JB Tue Jul 27 08:23 21/799 "test
charset"
& 2
Message 2:
From jb(a)localhost.localdomain Tue Jul 27 08:23:13 2010
Return-Path: <jb(a)localhost.localdomain>
From: JB <jb(a)localhost.localdomain>
Date: Tue, 27 Jul 2010 08:23:12 +0200
To: root(a)localhost.localdomain
Subject: test charset
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
Status: RO
A line of text.
&
JB