linux发送邮件的功能总结
生活随笔
收集整理的這篇文章主要介紹了
linux发送邮件的功能总结
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
使用linux系統(tǒng)服務(wù)器發(fā)送郵件的功能在平時工作中也是經(jīng)常需要用到的,在這里總結(jié)一下,供以后參考:
1、直接使用管道發(fā)送郵件
echo "hello,this is the content of mail.welcome to www.mzone.cc" | mail -s "Hello from mzone.cc by pipe" admin@qunar.com2、使用文本發(fā)送
mail -s "Hello from mzone.cc by file" admin@qunar.com < mail.txt3、如果希望修改發(fā)送郵件的人,那么:
mail -s "title" -r "from@qunar.com" to@qunar.com4、如果想要發(fā)送附件,那么:
echo "" | mutt -s "郵件名稱" qiu.li@qunar.com -c 抄送郵件列表 -a 附件路徑如果發(fā)送csv文件,很可能出現(xiàn)亂碼,那么需要提前將文件轉(zhuǎn)碼,命令是:
/usr/bin/iconv -t gb2312 -f utf-8 -c 源文件名 > 目標(biāo)文件名- -t 目標(biāo)編碼
- -f 原來編碼
5、從hive數(shù)據(jù)倉庫中提取數(shù)據(jù)并使用郵件發(fā)送,bash腳本如下
#!/bin/sh source /usr/local/model/hive_config.sh cd /home/username/shell-script/############################################## #Description:測試郵件方式導(dǎo)出數(shù)據(jù) #Author:username #CreateDate:2018-03-29#生成csv文件并轉(zhuǎn)碼 hive -e "select * from dw.ods_fmis_refund limit 10" > sample_refund.csv; (printf "\xff\xfe" ; iconv -c -f utf-8 -t utf-16le sample_refund.csv) > 訂單退款信息樣本20180329.csv;##壓縮文件,超過30M郵件無法加載 zip 訂單退款信息樣本20180329.csv.zip 訂單退款信息樣本20180329.csv#發(fā)送郵件 sendEmails "username@company.com" "【數(shù)據(jù)提取】訂單退款信息樣本20180329" "數(shù)據(jù)請見附件" "訂單退款信息樣本20180329.csv.zip"##發(fā)送短信
sendSmss "1342201****" "這是提醒短信! q(^o^)p"
#刪除文件 rm sample_refund.csv; rm -fr 訂單退款信息樣本20180329*
?
轉(zhuǎn)載于:https://www.cnblogs.com/shujuxiong/p/9105237.html
總結(jié)
以上是生活随笔為你收集整理的linux发送邮件的功能总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 博弈论模型总结
- 下一篇: python opencv3 检测人