需要sendmail或postfix服务
如果单纯的发文件文件可以用
cat xxxx.txt |mail -s "主旨" abc@xxx.com fff@xxx.com
如果需要发送附件需要安装uuencode来编码 (yum install sharutils)
单独发附件,这样xxxx@xxx.com会收到一个data.txt的附件
uuencode /tmp/data_process.log data.txt |mail xxx@xxx.com
如果需要正文和附件一起发:
uuencode /tmp/data_process.log data.txt > /tmp/data_temp.txt
上面是将编码的文件输出:
cat /tmp/data_temp.txt /tmp/data_process.log > /tmp/data_ok.txt
上面是将编码文件和内容合并
cat /tmp/data_ok.txt |mail -s "主旨" abc@xxx.com fff@xxx.com
上面是发送
发送HTML邮件:
#!/usr/bin/ksh
export MAILTO="recipient@mail.com"
export CONTENT="/tmp/example.html"
export SUBJECT="Example Report"
(
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
cat $CONTENT
) | /usr/sbin/sendmail $MAILTO
阅读(2409) | 评论(0) | 转发(0) |