3

When using mutt command:

mutt  -e "set content_type=text/plain"  -e "my_hdr From:[email protected]" -s "取样更多 サンプル 样品 text" -c "取样更多" -a "サンプル取样更多"

Now this mail will not be sent obviously, but the point is when I see the mail using sudo postsuper -q ID, subject of the mail is garbled, i.e.:

*** ENVELOPE RECORDS deferred/8/874FF381CDB ***
message_size:             682             346               2               0             682               3
message_arrival_time: Mon Sep 14 19:44:38 2020
create_time: Mon Sep 14 19:44:38 2020
named_attribute: rewrite_context=local
sender_fullname: My_name
sender: my_name@my-pc
named_attribute: dsn_orig_rcpt=rfc822;[email protected]
original_recipient: [email protected]
recipient: [email protected]
named_attribute: dsn_orig_rcpt=utf-8;取样更多@my-pc
original_recipient: 取样更多@my-pc
done_recipient: 取样更多@my-pc
*** MESSAGE CONTENTS deferred/8/874FF381CDB ***
Received: by my-pc (Postfix, from userid 1000)
    id 094FF381CDB; Mon, 14 Sep 2020 19:44:38 +0530 (IST)
Date: Mon, 14 Sep 2020 19:44:38 +0530
From: My_name <[email protected]>
To: [email protected]
Cc: 取样更多@my-pc
Subject: =?utf-8?B?5Y+W5qC35pu05aSaIOOCteODs+ODlw==?=
 =?utf-8?B?44OrIOagt+WTgQ==?= text
Message-ID: <20200914141438.GA4858@my-pc>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename*=utf-8''%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E5%8F%96%E6%A0%B7%E6%9B%B4%E5%A4%9A
Content-Transfer-Encoding: 8bit
User-Agent: Mutt/1.10.1 (2018-07-13)

サンプル body of the attached file in chinese 取样更多
*** HEADER EXTRACTED deferred/8/874FF381CDB ***
named_attribute: encoding=8bit
*** MESSAGE FILE END deferred/8/874FF381CDB ***

Now contents of ~/.muttrc is:

set config_charset=utf-8
set signature="iconv -f utf-8 ~/.signature |"
set charset="utf-8"
set send_charset="utf-8"
set rfc2047_parameters="yes"
set assumed_charset="utf-8"

Some important locale env variables are:

LANG=en_IN.utf8
LANGUAGE=
LC_CTYPE=en_IN.utf8
LC_NUMERIC=en_IN
LC_TIME=en_IN
LC_COLLATE="en_IN.utf8"
LC_MONETARY=en_IN
LC_MESSAGES=en_IN.utf8
LC_PAPER=en_IN
LC_NAME=en_IN
LC_ADDRESS=en_IN
LC_TELEPHONE=en_IN
LC_MEASUREMENT=en_IN
LC_IDENTIFICATION=en_IN
LC_ALL=

mutt -v is Mutt 1.10.1 (2018-07-13)

One important thing, my mails are saved in a file /var/mail/my_name, so If I cat this file using vim, or editor I still get same thing, but when I open this file using evolution, it shows everything correct.

4
  • Is it a bug report? Sep 14, 2020 at 14:43
  • @IporSircer, I don't know if it is a bug or I missed something.
    – Prvt_Yadav
    Sep 14, 2020 at 14:44
  • @IporSircer maybe missed something see my edit.
    – Prvt_Yadav
    Sep 14, 2020 at 14:46
  • The Subject header looks like normal base64 encoding of non-ASCII (UTF-8) characters. (I wonder why the Cc header is not encoded.)
    – Bodo
    Sep 14, 2020 at 15:37

1 Answer 1

2

The subject is not garbled. It's encoded in the MIME encoded-word format. There isn't a single standard encoding for email. The Content-Type header indicates the encoding of the body, but it doesn't apply to headers such as Subject. If a header contains non-ASCII characters, they need to be encoded in a format that indicates the encoding. That's where encoded-word comes into play.

=?utf-8?B?…?= is a word whose UTF-8 bytes are encoded in Base64. 5Y+W5qC35pu05aSaIOOCteODs+ODlw== is the Base64 representation of the bytes that represent 取样更多 in UTF-8.

$ echo '=?utf-8?B?5Y+W5qC35pu05aSaIOOCteODs+ODlw==?=
 =?utf-8?B?44OrIOagt+WTgQ==?= text' |
python3 -c '
import sys;
from email.header import decode_header;
print("".join(text.decode(encoding or "ascii") for text, encoding in decode_header(sys.stdin.read())))
'
取样更多 サンプル 样品 text

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .