Ubuntu上安装heirloom-mailx:
vim
sudo apt-get install heirloom-mailx
bash
配置sudo vim /etc/nail.rc服务器
添加网易163邮箱开放的须要认证的smtp服务器:
spa
set from=用户名@163.com命令行
set smtp=smtp.163.comorm
set smtp-auth-user=用户名get
set smtp-auth-password=密码it
set smtp-auth=login登录
等号两边不能有空格,被坑过配置
在用户的主目录下的.bashrc文件的最下面写上
echo '有人登陆服务器' `date` `who` |
mail -s "有用户登陆服务器 `who | cut -d'(' -f2 | cut -d')' -f1`" 接收邮件的邮箱@qq.com
在命令行发邮件给QQ邮箱用户:
echo "邮件内容" | heirloom-mailx -s "邮件标题" xxxxx@qq.com