• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
白_胖_子
Linux学习的生活就是这么朴实无华且枯燥
博客园    首页    新随笔    联系   管理    订阅  订阅

CentOS8安装本地mail工具-mailx-12.5-29.el8.x86_64

概述

服务器需要发告警邮件

查找是否已安装

[root@C8-1 ~]# type mail
-bash: type: mail: not found
[root@C8-1 ~]# which mailx
/usr/bin/which: no mailx in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)

查看yum信息

[root@C8-1 ~]# yum info mail
Last metadata expiration check: 0:09:24 ago on Sat 20 Jun 2020 06:21:53 PM EDT.
Error: No matching Packages to list
[root@C8-1 ~]# yum info mailx
Last metadata expiration check: 0:09:32 ago on Sat 20 Jun 2020 06:21:53 PM EDT.
Available Packages
Name         : mailx
Version      : 12.5
Release      : 29.el8
Architecture : x86_64
Size         : 257 k
Source       : mailx-12.5-29.el8.src.rpm
Repository   : BaseOS
Summary      : Enhanced implementation of the mailx command
URL          : http://heirloom.sourceforge.net/mailx.html
License      : BSD with advertising and MPLv1.1
Description  : Mailx is an enhanced mail command, which provides the functionality
             : of the POSIX mailx command, as well as SysV mail and Berkeley Mail
             : (from which it is derived).
             : 
             : Additionally to the POSIX features, mailx can work with Maildir/ e-mail
             : storage format (as well as mailboxes), supports IMAP, POP3 and SMTP
             : protocols (including over SSL) to operate with remote hosts, handles mime
             : types and different charsets. There are a lot of other useful features,
             : see mailx(1).
             : 
             : And as its ancient analogues, mailx can be used as a mail script language,
             : both for sending and receiving mail.
             : 
             : Besides the "mailx" command, this package provides "mail" and "Mail"
             : (which should be compatible with its predecessors from the mailx-8.x source),
             : as well as "nail" (the initial name of this project).

直接yum安装

[root@C8-1 ~]# yum info mailx
Last metadata expiration check: 0:09:32 ago on Sat 20 Jun 2020 06:21:53 PM EDT.
Available Packages
Name         : mailx
Version      : 12.5
Release      : 29.el8
Architecture : x86_64
Size         : 257 k
Source       : mailx-12.5-29.el8.src.rpm
Repository   : BaseOS
Summary      : Enhanced implementation of the mailx command
URL          : http://heirloom.sourceforge.net/mailx.html
License      : BSD with advertising and MPLv1.1
Description  : Mailx is an enhanced mail command, which provides the functionality
             : of the POSIX mailx command, as well as SysV mail and Berkeley Mail
             : (from which it is derived).
             : 
             : Additionally to the POSIX features, mailx can work with Maildir/ e-mail
             : storage format (as well as mailboxes), supports IMAP, POP3 and SMTP
             : protocols (including over SSL) to operate with remote hosts, handles mime
             : types and different charsets. There are a lot of other useful features,
             : see mailx(1).
             : 
             : And as its ancient analogues, mailx can be used as a mail script language,
             : both for sending and receiving mail.
             : 
             : Besides the "mailx" command, this package provides "mail" and "Mail"
             : (which should be compatible with its predecessors from the mailx-8.x source),
             : as well as "nail" (the initial name of this project).

[root@C8-1 ~]# yum -y install mailx
Last metadata expiration check: 0:10:34 ago on Sat 20 Jun 2020 06:21:53 PM EDT.
Dependencies resolved.
======================================================================================================================================
 Package                      Architecture                  Version                               Repository                     Size
======================================================================================================================================
Installing:
 mailx                        x86_64                        12.5-29.el8                           BaseOS                        257 k

Transaction Summary
======================================================================================================================================
Install  1 Package

Total download size: 257 k
Installed size: 491 k
Downloading Packages:
mailx-12.5-29.el8.x86_64.rpm                                                                          2.2 MB/s | 257 kB     00:00    
--------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                 160 kB/s | 257 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                              1/1 
  Installing       : mailx-12.5-29.el8.x86_64                                                                                     1/1 
  Running scriptlet: mailx-12.5-29.el8.x86_64                                                                                     1/1 
  Verifying        : mailx-12.5-29.el8.x86_64                                                                                     1/1 

Installed:
  mailx-12.5-29.el8.x86_64                                                                                                            

Complete!

安装好啦

[root@C8-1 ~]# type mail
mail is hashed (/usr/bin/mail)
[root@C8-1 ~]# rpm -qf /usr/bin/mail
mailx-12.5-29.el8.x86_64

在目录中配置smtp信息

[root@C8-1 ~]# cat .mailrc
set from=2……0@qq.com #邮箱地址
set smtp=smtp.qq.com #smtp服务器信息
set smtp-auth-user=2……0@qq.com #登录用户名
set smtp-auth-password=e……f #邮箱密码
set smtp-auth=login
set ssl-verify=ignore

发送邮件

[root@C8-1 ~]# echo "FBI Warning" | mail -s hellow 1……7@qq.com

华丽丽的收到邮件了

* * * 胖并快乐着的死肥宅 * * *
posted @ 2020-06-21 15:05  白_胖_子  阅读(858)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3