% mail --h
mail: illegal option -- -
Usage: mail -eiIUdEFntBDNHRV~ -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users
#!/bin/bash
#author:findyou
help(){
echo "eg: $0 [Subject] [address] [content_file] [file]"
echo ""
exit 1
}
if [ ! -n "$1" ] ; then
help
fi
cDate=`date +%Y%m%d`
if [ ! -n "$2" ] ; then
help
else
mail_to=$2
echo " Send Mail to ${mail_to}"
fi
if [ ! -n "$4" ] ; then
mail -s $1 ${mail_to}<$3
else
mail -s $1 -a $4 ${mail_to}<$3
fi
[root@123]$ ./sendmail.sh test 1968089885@qq.com abc.txt
Send Mail to 1968089885@qq.com
[root@123]$