安装Mailx到CentOS(YUM)

运行环境

系统版本:CentOS Linux release 7.3.1611 (Core)
软件版本:无
硬件版本:无

安装过程

1、配置网络

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.1.22
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=114.114.114.114
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# vi /etc/sysconfig/selinux
SELINUX=disabled
SELINUXTYPE=targeted
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive

2、配置YUM

[root@localhost ~]# rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache

3、安装Mailx

[root@localhost ~]# yum -y install mailx

4、配置个人邮箱

[root@localhost ~]# vi /etc/mail.rc
将下面配置添加到文件尾部
set smtp=smtp.163.com          # 邮箱服务器地址
set smtp-auth=login            # 认证方式:采用用户名和密码登录方式
set smtp-auth-user=xxx@163.com # 用户名
set smtp-auth-password=xxx     # 密码(邮箱授权码)
set from=xxx@163.com           # 绑定发件人

5、发送邮件

命令格式:echo '邮件内容' | mail -s '主题' <收件人>

[root@localhost ~]# echo 'hello world!' | mail -s '你好' xxx@qq.com 

我的QQ邮箱已经收到邮件啦!

乐在分享!~~
原文地址:https://www.cnblogs.com/network-ren/p/12377573.html