• 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
    

    华丽丽的收到邮件了

    * * * 胖并快乐着的死肥宅 * * *
  • 相关阅读:
    Django中的request对象和response对象(简单整理)
    Django基础--视图和URL配置
    javascript
    面向对象-01
    JS学习笔记
    云计算基础
    三种网络模式解析
    爬虫小问题
    http协议
    Django之WEB应用
  • 原文地址:https://www.cnblogs.com/bpzblog/p/13172478.html
Copyright © 2020-2023  润新知