Send mail through Msmtp+Mutt

Install Msmtp

msmtp is an SMTP client, which can send mail to the SMTP server.

1. Download ( official website address )

cd /usr/local
wget https://marlam.de/msmtp/releases/msmtp-1.8.12.tar.xz

2. Unzip, compile and install

cd /usr/local
tar -xf msmtp-1.8.12.tar.xz
cd msmtp-1.8.12
./configure --prefix=/usr/local/msmtp
make && make install
cd ..
rm -rf msmtp-1.8.12

Insert picture description here

3. Configuration

cat >~/.msmtprc <<EOF
#Set default values for all following accounts.
defaults
logfile /var/log/mmlog
#The SMTP server of the provider.
account test    #此处的test要和后面account default中的test一致
#SMTP邮件服务器地址
host smtp.163.com
#发送的邮件Email
from [email protected]
auth login
#邮件服务器登录账号
user [email protected]
#邮件服务器登陆密码
password *****YPUTM*****
#Set a default account
account default : test
EOF
touch /var/log/mmlog  #创建日志文件
chmod 600 ~/.msmtprc #赋予权限600
ln -s /usr/local/msmtp/bin/msmtp /usr/bin/msmtp  #创建软连接

4. Test and send email

msmtp [email protected]
test   #按ctrl+d

Insert picture description here
Insert picture description here
Insert picture description here

Install Mutt

Mutt is an email client. It cannot send emails directly. It is more responsible for email management functions. It can be used with msmtp. The combination of the two can play the role of foxmail. The official website address is http://www .mutt.org/.

1. Installation

yum install -y mutt

2. Configuration

Add the following configuration to the default configuration file

cat /etc/Muttrc
...
set sendmail='/usr/bin/msmtp'  #前面已经做好的软连接
set use_from=yes
set realname='wkx'  #自定义,邮件中显示的发件人名称
set from=[email protected]
set envelope_from=yes
auto_view text/html
set charset='utf-8'
set send_charset='utf-8'
set locale ='zh_CN.UTF-8'
set content_type = 'text/html\;charset=utf-8'
set rfc2047_parameters=yes
...

3. Test sending email

Insert picture description here
Insert picture description here
Test attachment
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44729138/article/details/109074910