centos7.6 发邮件配置记录

Posted tiantom

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7.6 发邮件配置记录相关的知识,希望对你有一定的参考价值。

Last login: Fri Mar 8 11:44:33 2019 from 172.16.5.80
[[email protected] ~]# rpm -qa|grep mailx
[[email protected] ~]# rpm -qa|grep mail
Last login: Fri Mar 8 21:58:45 2019 from 10.0.0.3
[[email protected] ~]# 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

完毕!
[[email protected] ~]# 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 [email protected]****.com #之前设置好的邮箱地址
set smtp=smtp.****.com #邮件服务器
set [email protected]****.com #之前设置好的邮箱地址
set smtp-auth-password=********* #授权码及密码
"/etc/mail.rc" 74L, 2225C 已写入
[[email protected] ~]# 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 [email protected]****.com #之前设置好的邮箱地址
set smtp=smtp.****.com #邮件服务器
set [email protected]****.com #之前设置好的邮箱地址
set smtp-auth-password=******* #授权码及密码
set smtp-auth=login #默认login<br>
[[email protected] ~]# mail -s "theme" [email protected]****.com < /etc/hosts
[[email protected] ~]# Could not resolve host: smtp.****.com
"/root/dead.letter" 12/448
. . . message not sent.
^C
[[email protected] ~]# 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 [email protected]****.com #之前设置好的邮箱地址
set smtp=smtp.****.com #邮件服务器
set [email protected]****.com #之前设置好的邮箱地址
set smtp-auth-password=******** #授权码及密码
"/etc/mail.rc" 74L, 2225C 已写入
[[email protected] ~]# mail -s "theme" [email protected]****.com < /etc/hosts   -----s 邮件主题为theme,[email protected]****.com为需要发送的邮箱,/etc/hosts为需要发送的内容,会把该文件的内容作为邮件内容发送;

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

 

------------

   

 

  

以上是关于centos7.6 发邮件配置记录的主要内容,如果未能解决你的问题,请参考以下文章

CentOs7.6配置邮件服务并发送邮件

不发邮件的问题处理

Linux学习-->如何通过Shell脚本实现发送邮件通知功能?

配置邮件告警

C# 如何配置公司邮箱发送邮件配置

在 SQL Server 2005 中配置数据库邮件