#mailx是一个邮件发送程序,像 sendmail  postfix
yum install mailx
#编辑mail配置文件
vi /etc/mail.rc
set from=123456@sina.com smtp=smtp.sina.com
set smtp-auth-user=123456@sina.com smtp-auth-password=b78e6f39cc4699ad
set smtp-auth=login
#发送邮件
#例子
#mail -s "标题" 邮件地址 < 要发送的文件
#mail -s "hello world" 623799533@qq.com </etc/hosts
#echo "正文"|mail -s "hello world" 623799533@qq.com
echo "this is liuzhe." |mail -s "monitor" 123456@sina.com
#!/bin/bash
#mailx是一个邮件发送程序
yum install mailx
#添加邮件账户,密码
cat >> /etc/mail.rc << EOF
set from=123456@sina.com smtp=smtp.sina.com
set smtp-auth-user=123456@sina.com smtp-auth-password=d2aa4bb9a942a7d2
set smtp-auth=login
EOF
#发送邮件"this is xiaozhezhe."到123456@sina.com
echo "this is xiaozhezhe." |mail -s "hello" 123456@sina.com