先建立好postfix能發信的環境

安裝套件yum -y install mutt

yum安裝的請注意 如果是1.4版以下的不支援content_type變數無法使用html寄信

1.4版會出現 “指令行有错:content_type:不明的变量”

可以到官網下載最新的tar包來安裝

http://www.mutt.org/

ftp://ftp.mutt.org/pub/mutt/

wget ftp://ftp.mutt.org/pub/mutt/mutt-1.5.24.tar.gz
tar zcvf mutt-1.5.24.tar.gz
cd  mutt-1.5.24
./configure
make && make install
ln -s /usr/local/bin/mutt /usr/bin/

檢查版本mutt -v

修改系統環境變量

vi /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
SYSFONT="latarcyrheb-sun16"

修改個人帳號環境變量

vi .bashrc
LANG="zh_CN.UTF-8"
SYSFONT="latarcyrheb-sun16"
vi .muttrc

請依照你的環境修改參數
set from = "[email protected]"
set realname = "您的名字"
set imap_user = "[email protected]"
set imap_pass = "password"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates
set smtp_url = "smtp://[email protected]:587/"
set smtp_pass = "password"
set move = no
set imap_keepalive = 900

建立mutt寄信用shell

mkdir mutt

abc.txt -----文章內文
mail.txt-----收件者信箱
mail-txt.sh------mutt寄信純文字
mail-html.sh------mutt寄信html格式

vi mail-txt.sh

#純文字寄信
#!/bin/sh    
i=1
while read rad    
do
cat abc.txt | mutt -s "測試Groups send a message"  $rad
    echo no.$i              #counter
    ((i+=1))
done < mail.txt

vi mail-html.sh

#!/bin/sh    
i=1
while read rad    
do
cat abc.txt | mutt -s "測試Groups send a message" -e "set content_type=text/html" $rad
    echo no.$i              #counter
    ((i+=1))
done < mail.txt

abc.txt 裡面就可以貼上 html 語法

查看q住的信
mailq
強制刪除背景的信
postsuper -d ALL
參考資料
http://cqfish.blog.51cto.com/622299/197893
http://ithelp.ithome.com.tw/question/10054431
http://www.ahlinux.com/shell/4394.htmlhttp://iplaylinux.com/check-mutt-version.htmlhttp://blog.xuite.net/tolarku/blog/58439089-Postfix+Mail+Queue+-+%E4%B8%80%E4%BA%9B%E7%B0%A1%E5%96%AE%E7%9A%84%E7%AE%A1%E7%90%86%E6%8C%87%E4%BB%A4

 

By tony

自由軟體愛好者~喜歡不斷的思考各種問題,有新的事物都會想去學習嘗試 做實驗並熱衷研究 沒有所謂頂天的技術 只有謙虛及不斷的學習 精進專業,本站主要以分享系統及網路相關知識、資源而建立。 Github http://stnet253.github.io

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料