HP-UX mailx傳送郵件出現中文亂碼問題

ljm0211發表於2012-06-20
cat filename | mailx -s "subject" lilianjia@zking.com
上面命令在傳送filename檔案內容中存在中文的時候會在Outlook中出現亂碼,檢視mail頭發現存在“charset="us-ascii",說明郵件使用us-ascii字符集解析了。

解決方法:在mailx命令加上-m引數
cat filename | mailx -m -s "subject" lilianjia@zking.com

-m 引數的意義
-m             Do not add MIME header lines Mime Version, Content
                          Type & Content Encoding to the header information
                          while sending mails.

確認下效果,不加-m引數的mail頭部:
Received: from zjop01.zking.com (88.0.33.4) by ZJ-MAIL01.zking.com (88.0.64.2)
with Microsoft SMTP Server id 8.0.685.24; Wed, 22 Apr 2009 13:37:22 +0800
Received: (from oraywzkr@localhost)    by zjop01.zking.com (8.11.1
(PHNE_35951)/8.11.1) id n3M5bMr07169    for lilianjia@zking.com; Wed, 22 Apr
2009 13:37:22 +0800 (EAT)
Date: Wed, 22 Apr 2009 13:37:22 +0800
From:
Message-ID: <200904220537.n3M5bMr07169@zjop01.zking.com>
To: lilianjia@zking.com
Subject: full_backup_200904220010.log
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8bit

Return-Path: oraywzkr@zjop01.zking.com

加上-m引數的mail頭部:
Received: from zjop01.zking.com (88.0.33.4) by ZJ-MAIL01.zking.com (88.0.64.2)
with Microsoft SMTP Server id 8.0.685.24; Wed, 22 Apr 2009 14:29:21 +0800
Received: (from oraywzkr@localhost)    by zjop01.zking.com (8.11.1
(PHNE_35951)/8.11.1) id n3M6TLc12667    for lilianjia@zking.com; Wed, 22 Apr
2009 14:29:21 +0800 (EAT)
Date: Wed, 22 Apr 2009 14:29:21 +0800
From:
Message-ID: <200904220629.n3M6TLc12667@zjop01.zking.com>
To: lilianjia@zking.com
Subject: full_backup_200904220010.log
MIME-Version: 1.0
Content-Type: text/plain
Return-Path: oraywzkr@zjop01.zking.com

郵件內容不再使用us-ascii解析,自然就沒有亂碼了。

發附件的方法:
uuencode filename filename | mailx -m -s "subject" lilianjia@zking.com
此處也必須加上-m引數,否則郵件會以亂碼的內容發出來。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11411056/viewspace-733493/,如需轉載,請註明出處,否則將追究法律責任。

相關文章