zoukankan      html  css  js  c++  java
  • centos7.6 定时发邮件配置记录

    Last login: Fri Mar 8 11:44:33 2019 from 172.16.5.80
    [root@vmhzpcentostest ~]# rpm -qa|grep mailx
    [root@vmhzpcentostest ~]# rpm -qa|grep mail
    Last login: Fri Mar 8 21:58:45 2019 from 10.0.0.3
    [root@vmhzpcentostest ~]# yum -y install sendmail mailx libreport-plugin-mailx sharutils mutt
    已加载插件:fastestmirror
    Loading mirror speeds from cached hostfile
    * base: mirrors.aliyun.com
    * extras: mirrors.aliyun.com
    * updates: mirrors.aliyun.com
    base | 3.6 kB 00:00
    extras | 3.4 kB 00:00
    updates | 3.4 kB 00:00
    正在解决依赖关系
    --> 正在检查事务
    ---> 软件包 libreport-plugin-mailx.x86_64.0.2.1.11-42.el7.centos 将被 安装
    --> 正在处理依赖关系 libreport = 2.1.11-42.el7.centos,它被软件包 libreport-plugin-mailx-2.1.11-42.el7.centos.x86_64 需要
    --> 正在处理依赖关系 libtar.so.1()(64bit),它被软件包 libreport-plugin-mailx-2.1.11-42.el7.centos.x86_64 需要
    --> 正在处理依赖关系 libsatyr.so.3()(64bit),它被软件包 libreport-plugin-mailx-2.1.11-42.el7.centos.x86_64 需要
    --> 正在处理依赖关系 libreport.so.0()(64bit),它被软件包 libreport-plugin-mailx-2.1.11-42.el7.centos.x86_64 需要
    --> 正在处理依赖关系 libaugeas.so.0()(64bit),它被软件包 libreport-plugin-mailx-2.1.11-42.el7.centos.x86_64 需要
    ---> 软件包 mailx.x86_64.0.12.5-19.el7 将被 安装
    ---> 软件包 mutt.x86_64.5.1.5.21-28.el7_5 将被 安装
    --> 正在处理依赖关系 urlview,它被软件包 5:mutt-1.5.21-28.el7_5.x86_64 需要
    --> 正在处理依赖关系 mailcap,它被软件包 5:mutt-1.5.21-28.el7_5.x86_64 需要
    --> 正在处理依赖关系 libgnutls.so.28(GNUTLS_1_4)(64bit),它被软件包 5:mutt-1.5.21-28.el7_5.x86_64 需要
    --> 正在处理依赖关系 libtokyocabinet.so.9()(64bit),它被软件包 5:mutt-1.5.21-28.el7_5.x86_64 需要
    --> 正在处理依赖关系 libgnutls.so.28()(64bit),它被软件包 5:mutt-1.5.21-28.el7_5.x86_64 需要
    ---> 软件包 sendmail.x86_64.0.8.14.7-5.el7 将被 安装
    --> 正在处理依赖关系 procmail,它被软件包 sendmail-8.14.7-5.el7.x86_64 需要
    --> 正在处理依赖关系 /usr/sbin/saslauthd,它被软件包 sendmail-8.14.7-5.el7.x86_64 需要
    --> 正在处理依赖关系 libhesiod.so.0()(64bit),它被软件包 sendmail-8.14.7-5.el7.x86_64 需要
    ---> 软件包 sharutils.x86_64.0.4.13.3-8.el7 将被 安装
    --> 正在检查事务
    ---> 软件包 augeas-libs.x86_64.0.1.4.0-6.el7_6.1 将被 安装
    ---> 软件包 cyrus-sasl.x86_64.0.2.1.26-23.el7 将被 安装
    ---> 软件包 gnutls.x86_64.0.3.3.29-8.el7 将被 安装
    --> 正在处理依赖关系 trousers >= 0.3.11.2,它被软件包 gnutls-3.3.29-8.el7.x86_64 需要
    --> 正在处理依赖关系 libnettle.so.4()(64bit),它被软件包 gnutls-3.3.29-8.el7.x86_64 需要
    --> 正在处理依赖关系 libhogweed.so.2()(64bit),它被软件包 gnutls-3.3.29-8.el7.x86_64 需要
    ---> 软件包 hesiod.x86_64.0.3.2.1-3.el7 将被 安装
    ---> 软件包 libreport.x86_64.0.2.1.11-42.el7.centos 将被 安装
    --> 正在处理依赖关系 libreport-python = 2.1.11-42.el7.centos,它被软件包 libreport-2.1.11-42.el7.centos.x86_64 需要
    --> 正在处理依赖关系 libreport-filesystem = 2.1.11-42.el7.centos,它被软件包 libreport-2.1.11-42.el7.centos.x86_64 需要
    ---> 软件包 libtar.x86_64.0.1.2.11-29.el7 将被 安装
    ---> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
    ---> 软件包 procmail.x86_64.0.3.22-36.el7_4.1 将被 安装
    ---> 软件包 satyr.x86_64.0.0.13-15.el7 将被 安装
    ---> 软件包 tokyocabinet.x86_64.0.1.4.48-3.el7 将被 安装
    ---> 软件包 urlview.x86_64.0.0.9-15.20121210git6cfcad.el7 将被 安装
    --> 正在检查事务
    ---> 软件包 libreport-filesystem.x86_64.0.2.1.11-42.el7.centos 将被 安装
    ---> 软件包 libreport-python.x86_64.0.2.1.11-42.el7.centos 将被 安装
    ---> 软件包 nettle.x86_64.0.2.7.1-8.el7 将被 安装
    ---> 软件包 trousers.x86_64.0.0.3.14-2.el7 将被 安装
    --> 解决依赖关系完成

    依赖关系解决

    ===============================================================================
    Package 架构 版本 源 大小
    ===============================================================================
    正在安装:
    libreport-plugin-mailx x86_64 2.1.11-42.el7.centos base 66 k
    mailx x86_64 12.5-19.el7 base 245 k
    mutt x86_64 5:1.5.21-28.el7_5 base 1.4 M
    sendmail x86_64 8.14.7-5.el7 base 736 k
    sharutils x86_64 4.13.3-8.el7 base 252 k
    为依赖而安装:
    augeas-libs x86_64 1.4.0-6.el7_6.1 updates 355 k
    cyrus-sasl x86_64 2.1.26-23.el7 base 88 k
    gnutls x86_64 3.3.29-8.el7 base 680 k
    hesiod x86_64 3.2.1-3.el7 base 30 k
    libreport x86_64 2.1.11-42.el7.centos base 455 k
    libreport-filesystem x86_64 2.1.11-42.el7.centos base 39 k
    libreport-python x86_64 2.1.11-42.el7.centos base 69 k
    libtar x86_64 1.2.11-29.el7 base 33 k
    mailcap noarch 2.1.41-2.el7 base 31 k
    nettle x86_64 2.7.1-8.el7 base 327 k
    procmail x86_64 3.22-36.el7_4.1 base 171 k
    satyr x86_64 0.13-15.el7 base 558 k
    tokyocabinet x86_64 1.4.48-3.el7 base 459 k
    trousers x86_64 0.3.14-2.el7 base 289 k
    urlview x86_64 0.9-15.20121210git6cfcad.el7 base 27 k

    事务概要
    ===============================================================================
    安装 5 软件包 (+15 依赖软件包)

    总下载量:6.2 M
    安装大小:20 M
    Downloading packages:
    (1/20): cyrus-sasl-2.1.26-23.el7.x86_64.rpm | 88 kB 00:02
    (2/20): augeas-libs-1.4.0-6.el7_6.1.x86_64.rpm | 355 kB 00:02
    (3/20): gnutls-3.3.29-8.el7.x86_64.rpm | 680 kB 00:02
    (4/20): hesiod-3.2.1-3.el7.x86_64.rpm | 30 kB 00:00
    (5/20): libreport-2.1.11-42.el7.centos.x86_64.rpm | 455 kB 00:00
    (6/20): libreport-filesystem-2.1.11-42.el7.centos.x86_64. | 39 kB 00:00
    (7/20): libreport-plugin-mailx-2.1.11-42.el7.centos.x86_6 | 66 kB 00:00
    (8/20): libtar-1.2.11-29.el7.x86_64.rpm | 33 kB 00:00
    (9/20): libreport-python-2.1.11-42.el7.centos.x86_64.rpm | 69 kB 00:00
    (10/20): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00
    (11/20): mailx-12.5-19.el7.x86_64.rpm | 245 kB 00:00
    (12/20): mutt-1.5.21-28.el7_5.x86_64.rpm | 1.4 MB 00:01
    (13/20): nettle-2.7.1-8.el7.x86_64.rpm | 327 kB 00:00
    (14/20): procmail-3.22-36.el7_4.1.x86_64.rpm | 171 kB 00:00
    (15/20): satyr-0.13-15.el7.x86_64.rpm | 558 kB 00:00
    (16/20): sharutils-4.13.3-8.el7.x86_64.rpm | 252 kB 00:00
    (17/20): sendmail-8.14.7-5.el7.x86_64.rpm | 736 kB 00:00
    (18/20): tokyocabinet-1.4.48-3.el7.x86_64.rpm | 459 kB 00:00
    (19/20): trousers-0.3.14-2.el7.x86_64.rpm | 289 kB 00:00
    (20/20): urlview-0.9-15.20121210git6cfcad.el7.x86_64.rpm | 27 kB 00:00
    -------------------------------------------------------------------------------
    总计 557 kB/s | 6.2 MB 00:11
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
    正在安装 : augeas-libs-1.4.0-6.el7_6.1.x86_64 1/20
    正在安装 : libtar-1.2.11-29.el7.x86_64 2/20
    正在安装 : satyr-0.13-15.el7.x86_64 3/20
    正在安装 : procmail-3.22-36.el7_4.1.x86_64 4/20
    正在安装 : mailcap-2.1.41-2.el7.noarch 5/20
    正在安装 : tokyocabinet-1.4.48-3.el7.x86_64 6/20
    正在安装 : mailx-12.5-19.el7.x86_64 7/20
    正在安装 : nettle-2.7.1-8.el7.x86_64 8/20
    正在安装 : cyrus-sasl-2.1.26-23.el7.x86_64 9/20
    正在安装 : urlview-0.9-15.20121210git6cfcad.el7.x86_64 10/20
    正在安装 : hesiod-3.2.1-3.el7.x86_64 11/20
    正在安装 : libreport-filesystem-2.1.11-42.el7.centos.x86_64 12/20
    正在安装 : libreport-2.1.11-42.el7.centos.x86_64 13/20
    正在安装 : libreport-python-2.1.11-42.el7.centos.x86_64 14/20
    正在安装 : trousers-0.3.14-2.el7.x86_64 15/20
    正在安装 : gnutls-3.3.29-8.el7.x86_64 16/20
    正在安装 : 5:mutt-1.5.21-28.el7_5.x86_64 17/20
    正在安装 : libreport-plugin-mailx-2.1.11-42.el7.centos.x86_64 18/20
    正在安装 : sendmail-8.14.7-5.el7.x86_64 19/20
    正在安装 : sharutils-4.13.3-8.el7.x86_64 20/20
    验证中 : 5:mutt-1.5.21-28.el7_5.x86_64 1/20
    验证中 : libreport-python-2.1.11-42.el7.centos.x86_64 2/20
    验证中 : libreport-2.1.11-42.el7.centos.x86_64 3/20
    验证中 : trousers-0.3.14-2.el7.x86_64 4/20
    验证中 : sendmail-8.14.7-5.el7.x86_64 5/20
    验证中 : libreport-filesystem-2.1.11-42.el7.centos.x86_64 6/20
    验证中 : libreport-plugin-mailx-2.1.11-42.el7.centos.x86_64 7/20
    验证中 : satyr-0.13-15.el7.x86_64 8/20
    验证中 : hesiod-3.2.1-3.el7.x86_64 9/20
    验证中 : libtar-1.2.11-29.el7.x86_64 10/20
    验证中 : urlview-0.9-15.20121210git6cfcad.el7.x86_64 11/20
    验证中 : sharutils-4.13.3-8.el7.x86_64 12/20
    验证中 : cyrus-sasl-2.1.26-23.el7.x86_64 13/20
    验证中 : augeas-libs-1.4.0-6.el7_6.1.x86_64 14/20
    验证中 : nettle-2.7.1-8.el7.x86_64 15/20
    验证中 : gnutls-3.3.29-8.el7.x86_64 16/20
    验证中 : mailx-12.5-19.el7.x86_64 17/20
    验证中 : tokyocabinet-1.4.48-3.el7.x86_64 18/20
    验证中 : mailcap-2.1.41-2.el7.noarch 19/20
    验证中 : procmail-3.22-36.el7_4.1.x86_64 20/20

    已安装:
    libreport-plugin-mailx.x86_64 0:2.1.11-42.el7.centos
    mailx.x86_64 0:12.5-19.el7
    mutt.x86_64 5:1.5.21-28.el7_5
    sendmail.x86_64 0:8.14.7-5.el7
    sharutils.x86_64 0:4.13.3-8.el7

    作为依赖被安装:
    augeas-libs.x86_64 0:1.4.0-6.el7_6.1
    cyrus-sasl.x86_64 0:2.1.26-23.el7
    gnutls.x86_64 0:3.3.29-8.el7
    hesiod.x86_64 0:3.2.1-3.el7
    libreport.x86_64 0:2.1.11-42.el7.centos
    libreport-filesystem.x86_64 0:2.1.11-42.el7.centos
    libreport-python.x86_64 0:2.1.11-42.el7.centos
    libtar.x86_64 0:1.2.11-29.el7
    mailcap.noarch 0:2.1.41-2.el7
    nettle.x86_64 0:2.7.1-8.el7
    procmail.x86_64 0:3.22-36.el7_4.1
    satyr.x86_64 0:0.13-15.el7
    tokyocabinet.x86_64 0:1.4.48-3.el7
    trousers.x86_64 0:0.3.14-2.el7
    urlview.x86_64 0:0.9-15.20121210git6cfcad.el7

    完毕!
    [root@vmhzpcentostest ~]# vim /etc/mail.rc
    # This is the configuration file for Heirloom mailx (formerly
    # known under the name "nail".
    # See mailx(1) for further options.
    # This file is not overwritten when 'make install' is run in
    # the mailx build process again.

    # Sccsid @(#)nail.rc 2.11 (gritter) 8/2/08

    # Do not forward to mbox by default since this is likely to be
    # irritating for most users today.
    set hold

    # Append rather than prepend when writing to mbox automatically.
    # This has no effect unless 'hold' is unset again.
    set append

    # Ask for a message subject.
    set ask

    # Assume a CRT-like terminal and invoke a pager.
    set crt

    # Messages may be terminated by a dot.
    set dot

    # Do not remove empty mail folders in the spool directory.
    # This may be relevant for privacy since other users could
    # otherwise create them with different permissions.

    # Do not remove empty private mail folders.
    set emptybox

    # Quote the original message in replies by "> " as usual on the Internet.
    set indentprefix="> "

    # Automatically quote the text of the message that is responded to.
    set quote

    # Outgoing messages are sent in ISO-8859-1 if all their characters are
    # representable in it, otherwise in UTF-8.
    set sendcharsets=iso-8859-1,utf-8

    # Display sender's real names in header summaries.
    set showname

    # Display the recipients of messages sent by the user himself in
    # header summaries.
    set showto

    # Automatically check for new messages at each prompt, but avoid polling
    # of IMAP servers or maildir folders.
    set newmail=nopoll

    # If threaded mode is activated, automatically collapse thread.
    set autocollapse

    # Mark messages that have been answered.
    set markanswered

    # Hide some header fields which are uninteresting for most human readers.
    ignore received in-reply-to message-id references
    ignore mime-version content-transfer-encoding

    # Only include selected header fields when forwarding messages.
    fwdretain subject date from to

    # For Linux and BSD, this should be set.
    set bsdcompat

    set from=exadmin@****.com #之前设置好的邮箱地址
    set smtp=smtp.****.com #邮件服务器
    set smtp-auth-user=exadmin@****.com #之前设置好的邮箱地址
    set smtp-auth-password=********* #授权码及密码
    "/etc/mail.rc" 74L, 2225C 已写入
    [root@vmhzpcentostest ~]# cat /etc/mail.rc
    # This is the configuration file for Heirloom mailx (formerly
    # known under the name "nail".
    # See mailx(1) for further options.
    # This file is not overwritten when 'make install' is run in
    # the mailx build process again.

    # Sccsid @(#)nail.rc 2.11 (gritter) 8/2/08

    # Do not forward to mbox by default since this is likely to be
    # irritating for most users today.
    set hold

    # Append rather than prepend when writing to mbox automatically.
    # This has no effect unless 'hold' is unset again.
    set append

    # Ask for a message subject.
    set ask

    # Assume a CRT-like terminal and invoke a pager.
    set crt

    # Messages may be terminated by a dot.
    set dot

    # Do not remove empty mail folders in the spool directory.
    # This may be relevant for privacy since other users could
    # otherwise create them with different permissions.
    set keep

    # Do not remove empty private mail folders.
    set emptybox

    # Quote the original message in replies by "> " as usual on the Internet.
    set indentprefix="> "

    # Automatically quote the text of the message that is responded to.
    set quote

    # Outgoing messages are sent in ISO-8859-1 if all their characters are
    # representable in it, otherwise in UTF-8.
    set sendcharsets=iso-8859-1,utf-8

    # Display sender's real names in header summaries.
    set showname

    # Display the recipients of messages sent by the user himself in
    # header summaries.
    set showto

    # Automatically check for new messages at each prompt, but avoid polling
    # of IMAP servers or maildir folders.
    set newmail=nopoll

    # If threaded mode is activated, automatically collapse thread.
    set autocollapse

    # Mark messages that have been answered.
    set markanswered

    # Hide some header fields which are uninteresting for most human readers.
    ignore received in-reply-to message-id references
    ignore mime-version content-transfer-encoding

    # Only include selected header fields when forwarding messages.
    fwdretain subject date from to

    # For Linux and BSD, this should be set.
    set bsdcompat
    set from=exadmin@****.com #之前设置好的邮箱地址
    set smtp=smtp.****.com #邮件服务器
    set smtp-auth-user=exadmin@****.com #之前设置好的邮箱地址
    set smtp-auth-password=******* #授权码及密码
    set smtp-auth=login #默认login<br>
    [root@vmhzpcentostest ~]# mail -s "theme" exadmin@****.com < /etc/hosts
    [root@vmhzpcentostest ~]# Could not resolve host: smtp.****.com
    "/root/dead.letter" 12/448
    . . . message not sent.
    ^C
    [root@vmhzpcentostest ~]# vim /etc/mail.rc
    set showname

    # Display the recipients of messages sent by the user himself in
    # header summaries.
    set showto

    # Automatically check for new messages at each prompt, but avoid polling
    # of IMAP servers or maildir folders.
    set newmail=nopoll

    # If threaded mode is activated, automatically collapse thread.
    set autocollapse

    # Mark messages that have been answered.
    set markanswered

    # Hide some header fields which are uninteresting for most human readers.
    ignore received in-reply-to message-id references
    ignore mime-version content-transfer-encoding

    # Only include selected header fields when forwarding messages.
    fwdretain subject date from to

    # For Linux and BSD, this should be set.
    set bsdcompat
    set from=exadmin@****.com #之前设置好的邮箱地址
    set smtp=smtp.****.com #邮件服务器
    set smtp-auth-user=exadmin@****.com #之前设置好的邮箱地址
    set smtp-auth-password=******** #授权码及密码
    "/etc/mail.rc" 74L, 2225C 已写入
    [root@vmhzpcentostest ~]# mail -s "theme" exadmin@****.com < /etc/hosts   -----s 邮件主题为theme,exadmin@****.com为需要发送的邮箱,/etc/hosts为需要发送的内容,会把该文件的内容作为邮件内容发送;

    [root@vmhzpcentostest ~]# echo "theme"|mail -s "theme" -a /etc/hosts exadmin@****.com  ---    -a添加附件,后面可以接多个邮箱群发,邮箱间以空格分割

    [root@vmhzpcentostest ~]# cd /home
    [root@vmhzpcentostest home]# vim mail.sh

    [root@vmhzpcentostest home]# cat mail.sh
    #!/bin/sh
    echo "定时邮件发送"|mail -s "定时邮件发送" -a /etc/hosts exadmin@****.com   < /etc/hosts
    [root@vmhzpcentostest home]#

    [root@vmhzpcentostest home]# crontab -e

    [root@vmhzpcentostest home]# crontab -l
    * */1 * * * bash /home/mail.sh    ----------每小时发一次邮件

     

      

  • 相关阅读:
    20200813质因数分解 --已知正整数n是两个不同的质数的乘积,试求出较大的那个质数 (奥赛一本通 P71 8)
    20200807求梯形面积,要求输入浮点数,输出精度为2位
    c++语言printf()输出格式大全 scanf()输入格式大全
    20200803给出一 名学生的语文和数学成绩,判断他是否恰好有一门课不及格(<60分),如果是输出1;否则输出0(奥赛一本通 p32 10)
    20200803-判断一个数能否同时被3,5,7整除(奥赛一本通 p32 9)
    20200802--利用公式 e=1+1/1!+1/2!+...+1/n!,求e的值, 要求保留小数点后10位(奥赛一本通 p67 2)
    20200802 给定正整数n,求不大于n的正整数的阶乘的和(即求1!+2!+...+n!),输出阶乘的和 (奥赛一本通p67 1题)
    线程
    mysql逻辑架构
    《python网络数据采集》笔记2
  • 原文地址:https://www.cnblogs.com/tiantom/p/10498714.html
Copyright © 2011-2022 走看看