mailx版本,這裡默認是mail是指向mailx程序的
- # ll /bin/mail
- lrwxrwxrwx. 1 root root 5 7月 22 2011 /bin/mail -> mailx
-
- # mail -V
- 12.4 7/29/08
mail.rc配置,設置外部smtp服務器
- cat /etc/mail.rc
- #set sendcharsets=iso-8859-1,utf-8
- set [email protected] smtp=smtp.163.com
- set smtp-auth-user=demo smtp-auth-password=demopassword smtp-auth=login
發送郵件,QQ郵箱裡無法看到內容,只看到一個附件。附件裡的內容就是我們發的中文內容
- #!/bin/bash
- ...
- echo "中文內容測試! " | /bin/mail -s "中文標題" [email protected]
- ...
但是手動輸入命令接收郵件內容卻顯示正常。或許是bash運行時系統編碼環境不通導致。查看系統編碼環境
- # locale
- LANG=zh_CN.gb18030
- LC_CTYPE="zh_CN.gb18030"
- LC_NUMERIC="zh_CN.gb18030"
- LC_TIME="zh_CN.gb18030"
- LC_COLLATE="zh_CN.gb18030"
- LC_MONETARY="zh_CN.gb18030"
- LC_MESSAGES="zh_CN.gb18030"
- LC_PAPER="zh_CN.gb18030"
- LC_NAME="zh_CN.gb18030"
- LC_ADDRESS="zh_CN.gb18030"
- LC_TELEPHONE="zh_CN.gb18030"
- LC_MEASUREMENT="zh_CN.gb18030"
- LC_IDENTIFICATION="zh_CN.gb18030"
- LC_ALL=
把發送命令更改為
- #!/bin/bash
- export LANG=zh_CN.gb18030
- echo "中文內容測試! " | /bin/mail -s "中文標題" [email protected]
- ...
則是接收郵件就正常顯示為中文了。