返回列表 发帖

CentOS8使用mailx

CentOS8使用阿里云的Yum源:
yum -y install wget
cd /etc/yum.repos.d/
rm -rf *

wget http://mirrors.aliyun.com/repo/Centos-8.repo
yum clean all
yum makecache

新的Yum源文件:
图片1.png
2020-10-25 10:27




设置使用Yum安装软件包时,保存软件包到服务器本地目录:(可选)
[root@centos8 ~]# vi /etc/yum.conf
追加:
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1


[root@centos8 ~]# cat /etc/yum.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1



查看Yum源上mailx的版本:
[root@centos8 ~]# yum list |grep mailx
libreport-plugin-mailx.x86_64   2.9.5-10.el8   AppStream
mailx.x86_64        12.5-29.el8         base


安装mailx:
[root@centos8 ~]# yum -y install mailx

[root@centos8 ~]# rpm -q mailx
mailx-12.5-29.el8.x86_64

[root@centos8 ~]# yum list |grep mailx
mailx.x86_64       12.5-29.el8         @base
libreport-plugin-mailx.x86_64    2.9.5-10.el8     AppStream
注释:第三列前面有 @ 代表已经安装了。


自动保存下来的软件包:
[root@centos8 ~]# cd /var/cache/yum/x86_64/8/
[root@centos8 8]# ls
AppStream-a5e033d33ad24141  base-43708d1174dbbac2  expired_repos.json       extras.solv
AppStream-filenames.solvx   base-filenames.solvx   extras-edb9f0658ab13c15
AppStream.solv              base.solv              extras-filenames.solvx
[root@centos8 8]#
[root@centos8 8]# find ./ -name "*.rpm"
./base-43708d1174dbbac2/packages/mailx-12.5-29.el8.x86_64.rpm



mailx的配置文件:(以下是使用126邮箱的25端口)
cat >/etc/mail.rc<< eof
set from=j13680432xxx@126.com
set smtp=smtp.126.com
set smtp-auth-user=j13680432xxx
set smtp-auth-password=密码
set smtp-auth=login
eof

注释:126邮箱为发送邮箱。


发送测试邮件:
[root@centos8 ~]# echo "Hello." | mail -s "Title" 2270168xxx@qq.com


QQ邮箱收到的邮件:
图片2.png
2020-10-25 10:30







######

把某个文本里的内容作为正文进行发送:
[root@centos8 ~]# pwd
/root
[root@centos8 ~]# echo 'Welcome to zhuohua' > xx.py
[root@centos8 ~]# mail -s "Title2" 2270168xxx@qq.com < /root/xx.py


QQ邮箱收到的邮件:
图片3.png
2020-10-25 10:30






当前系统的语言环境:(中文)
[root@centos8 ~]# echo $LANG
zh_CN.UTF-8
[root@centos8 ~]#
[root@centos8 ~]# cat /etc/locale.conf
LANG="zh_CN.UTF-8"


[root@centos8 ~]# pwd
/root
[root@centos8 ~]# echo '大家好。' > xx.py
[root@centos8 ~]# echo 'Welcome to zhuohua' >> xx.py
[root@centos8 ~]#
[root@centos8 ~]# mail -s "Title3" 2270168xxx@qq.com < xx.py


QQ邮箱收到的邮件:
图片4.png
2020-10-25 10:31







######

发送附加:
[root@centos8 ~]# pwd
/root
[root@centos8 ~]# ls *.txt
yy.txt
[root@centos8 ~]#
[root@centos8 ~]# echo 'Content..' | mail -s "Title8" -a /root/yy.txt 2270168xxx@qq.com


QQ邮箱收到的邮件:(附加可以正常下载、打开)
图片5.png
2020-10-25 10:32



备注:126邮箱发送这种邮件后,在“已发送”里是有记录的;












卸载软件包mailx:
[root@centos8 ~]# dnf -y remove mailx
[root@centos8 ~]#
[root@centos8 ~]# rpm -q mailx
未安装软件包 mailx


备注:软件包依然存在
[root@centos8 8]# pwd
/var/cache/yum/x86_64/8
[root@centos8 8]#
[root@centos8 8]# find ./ -name "*.rpm"
./base-43708d1174dbbac2/packages/mailx-12.5-29.el8.x86_64.rpm


离线使用Yum安装软件包:(以本地光盘作为Yum源)
[root@centos8 ~]# ls packages/
mailx-12.5-29.el8.x86_64.rpm
[root@centos8 ~]#
[root@centos8 ~]# dnf -y install packages/*rpm

[root@centos8 ~]# rpm -q mailx
mailx-12.5-29.el8.x86_64
[root@centos8 ~]#
[root@centos8 ~]# rpm -ql mailx
/bin/mail
/bin/mailx
/etc/mail.rc
/usr/bin/Mail
/usr/bin/nail
/usr/lib/.build-id
/usr/lib/.build-id/e0
/usr/lib/.build-id/e0/16cad374c96ed5dbda7f751ab0cc153815c49f
/usr/share/doc/mailx
/usr/share/doc/mailx/AUTHORS
/usr/share/doc/mailx/COPYING
/usr/share/doc/mailx/README
/usr/share/man/man1/Mail.1.gz
/usr/share/man/man1/mail.1.gz
/usr/share/man/man1/mailx.1.gz
/usr/share/man/man1/nail.1.gz





相关文章:
mail命令和screen命令
Windows客户端通过VNC Viewer远程桌面到CentOS7.8
CentOS8使用screen

CentOS8配置Yum源

返回列表