配置:
/etc/mail.rc 追加配置参数
set from=lynctest@iclinux.com smtp="mail.iclinux.com"
smtp-auth-user="iclinux"
set smtp-auth-password="iclinux@001122"
set smtp-auth=login
测试
echo
"邮件正文内容"
| mail -s
"邮件主题"
1968089885@foxmail.com
mail -s "邮件主题" 1968089885@foxmail.com -a /data/findyou.tar.gz < /data/findyou.txt
发件脚本
#!/bin/bash
#author:findyou
help(){
echo "eg: $0 [Subject] [address] [content_file] [file]"
echo ""
exit
} if [ ! -n "$1" ] ; then
help
fi cDate=`date +%Y%m%d` if [ ! -n "$2" ] ; then
help
else
mail_to=$
echo " Send Mail to ${mail_to}"
fi if [ ! -n "$4" ] ; then
mail -s $ ${mail_to}<$
else
mail -s $ -a $ ${mail_to}<$
fi