linux shell 发邮件

安装sendMail
yum -y install sendmail
1.使用管道进行邮件发送

[root@ProxyServer ~]# echo "hello,echo"|mail -s "echo" justin@51cto.com

2.使用外部smtp(qq的SMTP)来发送邮件
bin/mail会默认使用本地sendmail发送邮件,这样要求本地的机器必须安装和启动Sendmail服务,而通过修改配置文件/etc/mail.rc(/etc/nail.rc)可以使用外部SMTP服务器,可以达到不使用sendmail而用外部的smtp服务器发送邮件的目的。

[root@ProxyServer ~]# vim /etc/mail.rc          #文末添加以下
 set from=justin@51cto.com 
 set smtp=smtp.51cto.com
 set smtp-auth-user=justin@51cto.com 
 set smtp-auth-password=51cto 
 set smtp-auth=login
[root@ProxyServer ~]# source /etc/mail.rc
[root@ProxyServer ~]# mail -s "51cto" 15001*****@139.com < /etc/passwd
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值