# mutt邮箱

虽然说安卓手机里的邮箱客户端很多，好像终端邮箱也没有什么意义。但是需要批量发邮件的时候也是有一点用的。

```
pkg install mutt

# 发邮件
pkg install msmtp

# 终端浏览器
pkg install w3m
```

mutt配置文件.muttrc，以配置阿里邮箱为例:

```
set use_from=yes
set envelope_from=yes
set move=no
set include
set pager_stop
set pager_index_lines=4
set sort=reverse-date-received
set smart_wrap
set nomarkers
set mime_forward
set copy
#set beep_new=yes

set charset="utf-8"
set send_charset = "utf-8"
charset-hook !utf-8 gb2312
set assumed_charset="utf-8:gb2312:gb18030:gbk"
charset-hook ^us-ascii$ gb2312
charset-hook ^iso-8859-1$ gb2312
set rfc2047_parameters=yes

set from = "xxxxx@aliyun.com"
set realname = "zsxwz"

set imap_user = "xxxxx@aliyun.com"
set imap_pass = "xxxx"

set sendmail = "/data/data/com.termux/files/usr/bin/msmtp"
set use_from = yes
set envelope_from = yes

set folder = "imaps://imap.aliyun.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

auto_view text/html
alternative_order text/plain text/enriched text/html
```

配置发件.msmtprc:

```
account default
host smtp.aliyun.com
port 465
tls on
tls_starttls off
auth login
user xxxx@aliyun.com
password xxxxxxx
from xxxx@aliyun.com
tls_certcheck off
```

配置浏览器.mailcap:

```
text/html; w3m -dump -I $(echo %{charset} | sed s/gb2312/gbk/I) %s; nametemplate=%s.html; copiousoutput
```

使用shell发送邮件：

```
mutt -s "来自mutt的测试邮件" xxxx@qq.com <1.txt
# -s添加标题 ,<1.txt，正文内容来自1.txt
```

termux只是一个终端模拟器，linux玩法会更多一点，可以参考:

[Linux/Mac邮件客户端mutt添加谷歌gmail/微软outlook邮箱](https://zsxwz.com/2020/09/03/linux-mac%E9%82%AE%E4%BB%B6%E5%AE%A2%E6%88%B7%E7%AB%AFmutt%E6%B7%BB%E5%8A%A0%E8%B0%B7%E6%AD%8Cgmail-outlook%E9%82%AE%E7%AE%B1/)
