标签:arc nbsp splay ase word mail ack mirror var
邮件常常是Linux下监控报警手段之一。Linux下的mail命令可以方便,快速的完成发送邮件。下面以CentOS为例
1、安装
[root@vm8028 ~]# mail -bash: mail: command not found [root@vm8028 ~]# yum install mailx Loaded plugins: fastestmirror Determining fastest mirrors * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.net base | 3.7 kB 00:00 extras | 3.4 kB 00:00 extras/primary_db | 29 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 4.7 MB 00:04 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mailx.x86_64 0:12.4-8.el6_6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================================================================================================= Installing: mailx x86_64 12.4-8.el6_6 base 235 k Transaction Summary ============================================================================================================================================================================================================================================= Install 1 Package(s) Total download size: 235 k Installed size: 452 k Is this ok [y/N]: y Downloading Packages: mailx-12.4-8.el6_6.x86_64.rpm | 235 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : mailx-12.4-8.el6_6.x86_64 1/1 Verifying : mailx-12.4-8.el6_6.x86_64 1/1 Installed: mailx.x86_64 0:12.4-8.el6_6 Complete! [root@vm8028 ~]# mail No mail for root
2、配置
vi /etc/mail.rc 在文件尾加上如下配置 (注:因为163的设置相对简单些,以163邮箱为例,QQ邮箱等,其他邮箱因为安全等因素,需要设置的比较多,具体的可以搞下,本文不作重点。QQ邮箱也是可以的)
set from=xd502djj@163.com set smtp=smtp.163.com set smtp-auth-user=xd502djj@163.com set smtp-auth-password=邮箱密码 set smtp-auth=login
3、发送邮件测试
[root@vm8028 ~]# echo "Content" | mail -s "Title" dongjunjie@cmcm.com [root@vm8028 ~]# [root@vm8028 ~]#
4、其他
mail命令 可以使用查看具体更多的使用方法
mail --h
举例:
a、无邮件正文
# mail -s "Title" 280094177@qq.com
b、有邮件正文
# mail -s "Tile" 280094177@qq.com </root/sms_out.txt
或者 cat /root/sms_out.txt | mail -s "Tile" 280094177@qq.com
或者 echo “”Content“ | mail -s "Tile" 280094177@qq.com
c 、带附件的邮件
mail -s "Tile" 280094177@qq.com -a /root/sms_out.txt
标签:arc nbsp splay ase word mail ack mirror var
原文地址:http://www.cnblogs.com/xd502djj/p/7815306.html