使用mailx发送邮件的功能可以做很多事情,通常是通过脚本让宿主判断运行状态,发送邮件到指定邮箱。环境:虚拟机,CentOS7通过yum安装:yuminstall-ymailxyum安装很简单,需要注意的是mailx版本要大于7,发送邮件前需要通过redhat5系列自带的mailx发送sendmail程序,所以需要更新版本源码包安装:mailx-12.4cd#返回主目录tarxvjfmailx-12.4.tar.bz2&&cdmailx-12.4.tar.bz2#解压并进入./configure#编译checkmake&&makeinstall#Installconfiguration/etc/mail.rc(源码安装请配置/etc/nail.rc)setbsdcompatsetfrom=namesetsmtp=mailserversetsmtp-auth-user=mailaddresssetsmtp-auth-password=loginpasswordsetsmtp-auth=loginsendemailtestecho"你好,这是一封测试邮件!"|mail-s'主题'发送地址
