国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > Linux Shell > 正文

淺析linux下如何用腳本自動(dòng)發(fā)送文本mail郵件

2020-07-27 19:23:15
字體:
供稿:網(wǎng)友
1. 安裝msmtp

luther@gliethttp:~$ sudo apt-get install msmtp

2. 編輯配置腳本(~/.msmtprc是默認(rèn)配置文件,也可以使用-C選項(xiàng)指定配置文件路徑)

luther@gliethttp:~$ vim msmtprc
#添加如下內(nèi)容
defaults
#logfile /home/luther/msmtp.log
account luther_test
host mail.gliethttp.cn
from luther@gliethttp.cn
auth off
password 123456789
account default : luther_test

3. 去掉配置文件的執(zhí)行權(quán)限-x

luther@gliethttp:~$ chmod 600 msmtprc

4. 好了,可以使用下面語句發(fā)送一個(gè)測(cè)試郵件到自己的郵箱了,或者在stdin上輸入,然后ctrl+D

可能文件中的部分?jǐn)?shù)據(jù)會(huì)丟失,不怕,當(dāng)我們安裝mutt之后就一切正常了.
luther@gliethttp:~$ msmtp luther@gliethttp.cn -C /home/luther/msmtprc < /vobs/tmp/log.c

5. 接著安裝mutt

luther@gliethttp:~$ sudo apt-get install mutt

6. 編輯配置腳本(~/.muttrc是默認(rèn)配置文件,也可以使用-F選項(xiàng)指定配置文件路徑)

luther@gliethttp:~$ vim muttrc
#添加如下內(nèi)容
set sendmail="/usr/bin/msmtp -C /home/luther/msmtprc"
set use_from=yes
set from=admin@gliethttp.cn
set realname="測(cè)試admin"
set editor="vim"

7. 發(fā)送普通文本和文件內(nèi)容

luther@gliethttp:~$ echo "測(cè)試123abc" | mutt -F /home/luther/muttrc -s "郵件標(biāo)題 - 測(cè)試" luther@gliethttp.cn
luther@gliethttp:~$ mutt -F /home/luther/muttrc -s "郵件標(biāo)題 - 測(cè)試" luther@gliethttp.cn < /etc/passwd

8. 發(fā)送附件(-a選項(xiàng)用來添加附件,下面這個(gè)例子添加了passwd和resolv.conf這2個(gè)附件)

luther@gliethttp:~$ echo "測(cè)試123abc" | mutt -F /home/luther/muttrc -s "郵件標(biāo)題 - 測(cè)試" luther@gliethttp.cn -a /etc/passwd -a /etc/resolv.conf

9. bcc地址和cc抄送地址發(fā)送,如果多個(gè)郵件地址,使用逗號(hào)分隔即可

luther@gliethttp:~$ echo "測(cè)試123abc" | mutt -F /home/luther/muttrc -s "
郵件標(biāo)題 - 測(cè)試" luther@gliethttp.cn,luther.ge@163.com -b luther.ge@163.com,luther@gliethttp.cn -c   luther.ge@163.com,luther@gliethttp.cn
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 科技| 南康市| 曲阜市| 鄯善县| 长丰县| 将乐县| 从江县| 恩平市| 柏乡县| 子洲县| 屯门区| 吴旗县| 辽中县| 七台河市| 黑河市| 清涧县| 武鸣县| 阿拉善左旗| 长寿区| 卢龙县| 平度市| 会宁县| 蛟河市| 广宁县| 科尔| 达孜县| 西贡区| 图木舒克市| 浮山县| 新丰县| 屏南县| 灵璧县| 新源县| 新和县| 梁平县| 桃江县| 彭泽县| 延川县| 霍州市| 建始县| 华亭县|