设定:
#/bin/bash
mailaddr=test@163.comsmtpserver=smtp.163.com
user=onovps
passwd=onovps
cat >> /etc/mail.rc <<EOF
set from=$mailaddr
set smtp=$smtpserver
set smtp-auth=login
set smtp-auth-user=$user
set smtp-auth-password=$passwd
EOF
用法:
cat xxx.txt|mail -v -s "test" test@163.commail -v -s "test" test@163.com
mail -v -s "test" test@163.com < file
echo "xxx"|mail -v -s "test" test@163.com