Linux实战(17):Linux配置用户登陆时发送邮件到指定邮箱

参考其他文章,正好有这个需求,记一笔做个记录,以防丢失。 参考链接

#!/bin/bash
yum install -y mailx
cat >> /etc/mail.rc<< EOF
#set from=server@domainname.com    #发件箱
#set smtp=smtp.exmail.qq.com               #smtp地址,腾讯企业邮就是这个了
#set smtp-auth-user=server@domainname.com
#set smtp-auth-password=vT6K1234543XdsqV   ##<--这里填的是邮箱授权码
#set smtp-auth=login
EOF
vim /etc/bashrc #末尾添加已下命令
echo 'ALERT - Root Shell Access (vps.ehowstuff.com) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" samgg@domainname.com
source /etc/bashrc
原文地址:https://www.cnblogs.com/98record/p/13648574.html