Linux下配置用msmtp和mutt发邮件

https://blog.csdn.net/qq_14806125/article/details/50962343

一、安装mutt

yum install mutt
二、配置mutt
vi /etc/Muttrc
找到以下几行内容,并修改为您自己的内容(以下几行分布在不同的位置,请耐心查找,并记得去掉行首的#)

[En]

Find the following lines inside and modify the content to your own (the following lines are distributed in different locations, please look for them patiently, and remember to remove the # at the beginning of the line)

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 “邮件主题” 收件者邮箱
一切正常的话,收件者的邮箱是可以接受到邮件的。
七、用途

之所以设置发送邮件程序,是因为如果需要在服务器管理中提示管理员,可以通过发送邮件的方式来提醒管理员。

[En]

The reason for setting up the program to send mail is that if you need to prompt the administrator in the server management, you can use the way to send email to remind the administrator.

比如,每天定期查看磁盘占有率,如果占有率高,就发邮件提醒管理员该处理了。

[En]

For example, check the disk occupancy regularly every day, and if the occupancy rate is high, send an email to remind the administrator that it is time to deal with it.

其他用途,各位可以根据你们的需要来自己写脚本。
–> 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
–> 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
–> 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

Original: https://www.cnblogs.com/canyangfeixue/p/9845484.html
Author: 残阳飞雪
Title: Linux下配置用msmtp和mutt发邮件

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/10328/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

发表回复

登录后才能评论
免费咨询
免费咨询
扫码关注
扫码关注
联系站长

站长Johngo!

大数据和算法重度研究者!

持续产出大数据、算法、LeetCode干货,以及业界好资源!

2022012703491714

微信来撩,免费咨询:xiaozhu_tec

分享本页
返回顶部