https://blog.csdn.net/qq_14806125/article/details/50962343
一、安装mutt
yum install mutt
二、配置mutt
vi /etc/Muttrc
在里面找到下面几行,并将内容修改为你自己的内容(下面几行分布在不同位置,请耐心查找,记得去掉它行首的#号)
set from="发送邮件地址"
set sendmail="/usr/local/msmtp/bin/msmtp"
set use_from=yes
set realname="发件人姓名"
set editor="vim"
三、下载并解压msmtp
wget http://downloads.sourceforge.net/msmtp/msmtp-1.4.30.tar.bz2?big_mirror=0
tar jxvf msmtp-1.4.30.tar.bz2
四、编译msmtp
解压好之后,进入解压目录,并运行如下语句
./configure --prefix=/usr/local/msmtp
make
make install
五、配置msmtp
cd /usr/local/msmtp
mkdir etc
cd etc
vi msmtprc 在文件里面加入如下内容:
defaults
logfile /usr/local/msmtp/msmtp.log #指定log的位置
# The SMTP server of the provider.
account test
# SMTP邮件服务器地址
host smtp.qq.com
# 用来发送邮件Email
from xxxxx@qq.com
auth login
# 用来发送邮件的账号账号
user xxxxxx@qq.com
# 用来发邮件的账号的登陆密码登陆密码
password 123456
# Set a default account
account default: test
保存退出
因为密码是明文的,所以此处最好修改文件的权限:chmod 600 msmtprc
六、测试
根据以上配置配置好之后就可以进行测试,运行一下语句
echo "邮件内容" |mutt -s "邮件主题" 收件者邮箱
一切正常的话,收件者的邮箱是可以接受到邮件的。
七、用途
之所以搭建用来发送邮件的程序,是因为服务器管理中如果需要提示管理员的时候,可以使用发送邮件的方式进行提醒。
比如,每天定时检测磁盘的占用率,如果占用率高的话,便发送邮件提示管理员该来处理一下。
其他用途,各位可以根据你们的需要来自己写脚本。
---------------------
作者:wiggin_wj
来源:CSDN
原文:https://blog.csdn.net/qq_14806125/article/details/50962343
版权声明:本文为博主原创文章,转载请附上博文链接!
过程中遇到了下面的问题
https://blog.csdn.net/duguduchong/article/details/8699774
[root@localhost ~]# cd msmtp-1.4.20
[root@localhost msmtp-1.4.20]# ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/msmtp-1.4.20':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
今天在安装msmtp的时候遇到了这个问题,解决办法如下:
安装GCC软件套件
[root@localhost ~]# yum install gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror01.idc.hinet.net
* extras: mirror01.idc.hinet.net
* updates: mirror01.idc.hinet.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.i386 0:4.1.2-50.el5 set to be updated
--> Processing Dependency: cpp = 4.1.2-50.el5 for package: gcc
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
--> Running transaction check
---> Package cpp.i386 0:4.1.2-50.el5 set to be updated
---> Package glibc-devel.i386 0:2.5-58.el5_6.3 set to be updated
--> Processing Dependency: glibc-headers = 2.5-58.el5_6.3 for package: glibc-devel
--> Processing Dependency: glibc-headers for package: glibc-devel
--> Running transaction check
---> Package glibc-headers.i386 0:2.5-58.el5_6.3 set to be updated
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
--> Processing Dependency: kernel-headers for package: glibc-headers
--> Running transaction check
---> Package kernel-headers.i386 0:2.6.18-238.9.1.el5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gcc i386 4.1.2-50.el5 base 5.2 M
Installing for dependencies:
cpp i386 4.1.2-50.el5 base 2.7 M
glibc-devel i386 2.5-58.el5_6.3 updates 2.0 M
glibc-headers i386 2.5-58.el5_6.3 updates 603 k
kernel-headers i386 2.6.18-238.9.1.el5 updates 1.1 M
Transaction Summary
================================================================================
Install 5 Package(s)
Upgrade 0 Package(s)
Total download size: 12 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): glibc-headers-2.5-58.el5_6.3.i386.rpm | 603 kB 00:00
(2/5): kernel-headers-2.6.18-238.9.1.el5.i386.rpm | 1.1 MB 00:00
(3/5): glibc-devel-2.5-58.el5_6.3.i386.rpm | 2.0 MB 00:00
(4/5): cpp-4.1.2-50.el5.i386.rpm | 2.7 MB 00:00
(5/5): gcc-4.1.2-50.el5.i386.rpm | 5.2 MB 00:00
--------------------------------------------------------------------------------
Total 5.1 MB/s | 12 MB 00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : kernel-headers 1/5
Installing : cpp 2/5
Installing : glibc-headers 3/5
Installing : glibc-devel 4/5
Installing : gcc 5/5
Installed:
gcc.i386 0:4.1.2-50.el5
Dependency Installed:
cpp.i386 0:4.1.2-50.el5 glibc-devel.i386 0:2.5-58.el5_6.3
glibc-headers.i386 0:2.5-58.el5_6.3 kernel-headers.i386 0:2.6.18-238.9.1.el5
Complete!
[root@localhost ~]# cd msmtp-1.4.20
[root@localhost msmtp-1.4.20]# ./configure
成功了!!