Linux系统配置Msmtp&Mutt收发邮件

问题描述:利用Mutt结合Msmtp在运行Linux系统的主机收发邮件

解决方案:

(一)、 Msmtp安装与配置

1. Linux系统安装Msmtp

1.1 下载msmtp-1.6.6.tar.xz
1.2 运行以下命令进行安装

tar Jvxf msmtp-1.6.6.tar.xz
cd msmtp-1.6.6
./configure
make && make install
2. Linux系统配置Msmtp

2.1 创建.msmtp.log文件

touch ~/.msmtp.log

2.2 创建.msmtprc文件并更改文件权限为600

touch ~/.msmtprc 
chmod 600 ~/.msmtprc

2.3 编辑.msmtprc文件为以下内容

defaults
logfile ~/.msmtp.log

# gmail

account Gmail

tls on
auth on

host smtp.gmail.com
port 587

tls_certcheck off

user *** # your username instead of your mail account
password *********
3. Linux系统运行Msmtp
echo "This is a test email from msmtp" | msmtp [email protected]

(二)、Mutt安装与配置

1. Linux系统安装mutt

1.1 Centos系统

yum install mutt

1.2 Arch linux系统

pacman -S mutt

1.3 Ubuntu系统

apt-get install mutt

2. 配置mutt

2.1 创建.~/.muttrc文件,并将以下内容写入.muttrc文件。

set from = "[email protected]"
set realname = "username"

set imap_user = "[email protected]"
set imap_pass = "password"
set imap_keepalive = 900

set sendmail = "/usr/local/bin/msmtp" #path depends on where you install msmtp, if you don't know try "which msmtp"
set use_from = yes
set envelope_from = yes

set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates

set move = no
set editor = vim

2.2 创建mutt和cache文件夹用于储存信件头和信件正文。

mkdir -p ~/.mutt/cache

3.运行实例

3.1 运行以下命令,对mutt命令进行测试。

echo "Test email" | mutt -s "Test" [email protected]

3.2 运行mutt在图形用户界面查看来往信件及发送邮件。

4. 参考链接

  1. https://hostpresto.com/community/tutorials/how-to-send-email-from-the-command-line-with-msmtp-and-mutt/
  2. www.garron.me/en/go2linux/send-mail-gmail-mutt.html

你可能感兴趣的:(Linux系统配置Msmtp&Mutt收发邮件)