Charset problem with mailx


I run into a problem with charsets and mailx.

My setup is:

SuSE-11-1, LANG=de_CH, Console using iso-8859-1 (no UTF-8)

Task: Apache (user wwwrun) sends email from a *.cgi script which is a bash script. German language with umlauts is used. The relevant part of the script looks like this:

echo "$MSG" | env MAILRC=/dev/null \
ttycharset=iso-8859-1 sendcharsets=iso-8859-1 \
mailx -n -s "$SUBJ" \
-a "${DOC}.pdf" \
-c "" -r "" \

Looking at the received message with pine shows:

   1 Shown    11 lines  Text (charset: UTF-8)
   2   OK     31 KB     Application

Pine’s display character set is set to ISO-8859-1. Looking at the mailbox file reveals that the message is indeed encoded in UTF-8. However, the text fed into mailx is iso-8859-1.

Any ideas what I can do to send messages in the iso-8859-1 character set?

Ok, responding to myself :wink:

The solution is as simple as this: mailx in SuSE-11.1 is broken. Upgrading to the latest version 12.4 of Heirloom mailx solves the problem. Sources can be found at Heirloom mailx.

Correct usage would be:

echo "Some message" | mailx -s "The subject" -a attachment.pdf -S ttycharset=iso-8859-1 -S sendcharsets=iso-8859-1 -S encoding=8bit mail.user@domain.tld