在shell脚本中通过sendmail做邮件通知发送
时间:2008-11-10 来源:jody1212
- #param $1 the file name that contain message to send
- #param $2 message title
- #param $3 to mail box
- #param $4 from mail box
- function do_send_mail()
- {
- local emailname=$3
- local email=$3
- local fromname=$4
- local from=$4
- local subject=$2
- local messagebody=$1
- echo -e "To: \"${emailname}\" <${email}>\nFrom: \"${fromname}\" <${from}>\nSubject: ${subject}\n\n`cat ${messagebody}`" | /usr/sbin/sendmail -t
- }
比如我要将以[email protected]的身份将消息 hello 发送给 [email protected],可以像下面这样使用。
- echo "hello" > /tmp/tmpmail.tmp
- do_send_mail /tmp/tmpmail.tmp hello [email protected] [email protected]
- rm /tmp/tmpmail.tmp
相关阅读 更多 +
- 系统休眠文件删除后果 如何删除计算机的休眠文件 2025-04-22
- 站群服务器是什么意思 站群服务器的作用 站群服务器和普通服务器的区别 2025-04-22
- jQuery插件有何作用 jQuery插件的使用方法 2025-04-22
- jQuery插件有哪些种类 简单的jQuery插件实例 2025-04-22
-