linux傳送郵件的shell指令碼

2021-03-31 08:56:29 字數 1204 閱讀 1460

#!/bin/sh

function echo_help()

email="to@toaddress.***"

emailname="test mail"

messagebody="tmp.tmp"

from="from@fromaddress.***"

fromname="mailreport"

subject="mail report"

until [ $# -eq 0 ]

do?tmpv=$1

?if [ $tmpv = "-from" ] ; then

??shift

??tmpv=$1

??from=$tmpv

?elif [ $tmpv = "-to" ] ; then

??shift

??tmpv=$1

??email=$tmpv

?elif [ $tmpv = "-subject" ] ; then

??shift

??tmpv=$1

??subject=$tmpv

?elif [ $tmpv = "-file" ] ; then

??shift

??tmpv=$1

??messagebody=$tmpv

?elif [ $tmpv = "-fname" ] ; then

??shift

??tmpv=$1

??fromname=$tmpv

?elif [ $tmpv = "-tname" ] ; then

??shift

??tmpv=$1

??emailname=$tmpv

?elif [ $tmpv = "--help" -o $tmpv = "-h" ] ; then

??echo_help

??exit 1

?fi?shift

done

if ! test -f $ ; then

?echo "$ not exists!"

?echo_help

?exit 2

fiecho "begin send..."

echo -e "to: /"$/" <$>/nfrom: /"$/" <$>/nsubject: $/n/n`cat $`" | /usr/sbin/sendmail -t

echo "send ok."

Shell 傳送郵件

1.確認mail安裝 rpm qa grep mail 如未安裝 yum install mailx ll usr bin mail 2.配置郵箱設定項 引用外部smtp伺服器 etc mail.rc set from telent qq.com set smtp smtp.qq.com set s...

shell的傳送郵件

shell中的傳送郵件,可以做報警用 傳送郵件的配置檔案 mail.conf cbd2003 163.com abc2003 gmail.com 傳送郵件的主程式 傳送郵件shell指令碼,必須傳入兩個引數,第一個為標題,第二個為郵件內容,必須要有mail.conf檔案,裡面是郵件列表,一行一個郵件...

linux通過shell指令碼傳送網路郵件

很多運維人員在做一些簡單監控的指令碼時,需要對監控內容能夠及時反饋,比如監控cpu使用率達到50 就會收到警告,這時候郵件起了很大的作用,那麼如何在shell指令碼中呼叫郵件工具呢,這裡有一個簡便的方法 這時我們需要把登入資訊下如mail程式 在檔案 etc mail.rc中新增如下兩行 set f...

Linux傳送郵件

linux傳送郵件命令 mail 如果沒有mail命令 yum y install postfix 如果只是傳送郵件不接收郵件的時候postfix不用開啟 例1 echo 正文內容 mail s 郵件標題 xx xx.com 例2 mail s 郵件標題 xx xx.com etc hosts 把h...

傳送統計郵件shell指令碼

user aaa port 3306 password aaa database aaa today date y m d yesterday date y m d date 1 day host aaa send mail name lipingchang pystandard.com weiji...