IT序号网

配置mutt知识解答

xmjava 2021年05月25日 程序员 153 0
  1. 安装 mutt brew install mutt
  2. 配置 .muttrc

网上的配置教程

我的配置文件:

## .muttrc 
## Purpose: $HOME/.muttrc for mutt 
## Author: IOU 
## Last Update: 04-22-2013 
## Setting: chmod 600 .muttrc 
 
## 一些必需的全局设置 
set sendmail="/usr/local/bin/msmtp"           # 用 msmtp 发邮件 
# set hostname=smtp.mxhichina.com             # local host 
#set hidden_host                            # 隐藏 host 细节 
set editor="mvim"                            # 用 vim 作编辑器 
set record="~/mail/sent-`date +%Y-%m`"      # 每月发出的信件放在不同的文件里 
set use_from=yes                            # 让 msmtp 知道用哪个帐号 
set from=zhaochunjie@sourcod.com            # 缺省地从这个邮箱发邮件 
set realname="willeamZhao"                  # 真实姓名 
set envelope_from=yes                       # 让 mutt 使用 msmtp 的 -f 选项 
set ispell="/usr/local/bin/aspell"          # 英文拼写检查 aspell 
 
## 在多个邮件帐号之间切换 
macro generic "<esc>1" ":set from=zhaochunjie@sourcod.com" 
macro generic "<esc>2" ":set from=zhaochunjie.love@163.com" 
macro generic "<esc>3" ":set from=zhaochunjie.love@outlook.com" 
 
## 建立信箱 
set folder=~/mail                           # 邮箱目录 
# set mbox=~/mail/incoming 
set mbox="~/mail/inbox"                       # 缺省的邮箱 
set spoolfile="~/mail/inbox"                  # 收件箱 
set postponed="~/mail/postponed"              # 推迟发送 
 
# source $HOME/.mutt.alias 
set alias_file="~/.mutt.alias"                # 别名 
 
set fast_reply=yes                          #回复时不询问回复地址 
 
## 邮件格式 
my_hdr From: zhaochunjie@sourcod.com        # 缺省的发件地址 
my_hdr Reply-To: zhaochunjie@sourcod.com    # 缺省的回复地址 
set index_format="| %4C | %Z | %{%b %d} | %-15.15L | %s" 
set folder_format="| %2C | %t %N | %8s | %d | %f" 
macro index G "!fetchmail -a -m 'procmail -d %T'\r" 
macro pager G "!fetchmail -a -m 'procmail -d %T'\r" 
set include=yes                             # 回信时包含原文 
set indent_str="> "                         # 回信的引文之前插入符号 > 
 
## 对收到的邮件进行打分和排序 
score "~N" +4                               # 新信件 +4 分 
score "~s 通知" +2                          # 主题包含“通知”的 +2 
score "~s Circulation" +3                   # 主题包含 “Circulation” +3 
score "~D" -5                               # 已经标记删除的 -5 
score "~O" +1                               # 上次没有读的 +1 
score "~s believe" -10                      # 包含 believe 的 -10,垃圾广告! 
set sort=reverse-date-received            # 邮件按日期由近及远排列 
set sort_aux=score                              # 按打分排序 
 
## 编码以及中文设置 
#set locale="zh_CN.UTF-8"                   # 使用中文 
set ascii_chars=yes                         # 用纯 ascii 表示树状列表 
set charset="utf-8"                         # 编码以及发件编码 
set send_charset="us-ascii:iso-8859-1:gb2312:utf-8" 
set rfc2047_parameters=yes                  # 解决中文附件名是乱码的问题 
charset-hook ^iso-8859-1$ gb2312            # 把 iso-8859-1 编码映射到 gb2312 
charset-hook !utf-8 gb2312                  # 把不是 utf-8 的编码都映射到 gb2312 
charset-hook ^us-ascii$ gb2312              # 把 us-ascii 编码映射到 gb2312 
 
## 颜色设置:前景色+背景色 
color normal     white        default       # 背景色选 default 实现透明 
color attachment yellow       default       # 附件:黄色 
color bold       brightwhite  default       # 粗体:亮黄色 
color underline  default      blue          # 下划线:蓝色 
color error      brightwhite  default       # 错误:亮白色 
color indicator  white        blue 
color message    brightblue   default       # 消息:亮蓝色 
color status     white        default       # 状态:白色 
color header     brightgreen  default ^From: 
color header     brightcyan   default ^To: 
color header     brightcyan   default ^Reply-To: 
color header     brightcyan   default ^Cc: 
color header     brightred    default ^Subject: 
color body       brightwhite  default [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+ 
color body       brightblue   default (https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+ 
color index      brightyellow default ~N 
 
## 个人使用习惯 
set edit_headers=yes                      # 允许编辑邮件头 
set header=no                             # 回复时不加入邮件头 
set nomark_old                            # 未读新邮件别标注为旧邮件 
set copy                                  # 保留已发邮件的备份 
set beep_new=yes                          # 来新邮件时,蜂鸣 
set smart_wrap                            # 禁止从单词中间断行 
set nomarkers                             # 禁止换行标记 
set mime_forward                          # 转发的邮件 MIME 附件 
set pager_index_lines=6                   # 看信时,在 index 留出多少行显示邮件列表? 
set pager_context=3                       # Display 3 lines of context in pager 
set nostrict_threads                      # Lets have some fuzzy threading 
#set wait_key=yes                         # 外部程序退出时,要求用户按键返回 
set sendmail_wait=-1                      # Don't wait around for sendmail 
set fcc_clear                             # Keep fcc's clear of signatues and encryption 
set nopipe_decode                         # Don't decode messages when piping 
set tilde                                 # 过滤带 ~ 的邮件 
set read_inc=100                          # Read counter ticks every 100 msgs 
set write_inc=100                         # Write counter ticks every 100 msgs 
set noconfirmappend                       # Just append, don't hassle me 
set pager_stop                            # Don't skip msgs on next page 
set resolve=yes                           # 按 "t""D" 时,自动移动光标到下封信件 
set fast_reply                            # 按 "r" 回信时,直接进入编辑模式 
set quit=yes                              # 退出时,直接退出 
set postpone=ask-no                       # 推迟发送 
set nomove                                # 邮件保留在 $MAIL 
set delete=ask-yes                        # 删除前询问 
ignore x-mailer                           # 忽略 x-mailer 邮件头 
auto_view text/html application/msword    # 让 mutt 自动浏览邮件中 text/html 的那部分 
 
## 监视下面几个邮箱,随时报告新邮件 
set check_new=yes                         # 查是否有新邮件 
set mail_check=60                         # 每 60 分钟查一次 
set timeout=30 
 
# HTML 是最后的选择 
alternative_order text/enriched text/plain text/html 
 
subscribe zhaochunjie.love@163.com 
 
# application/pdf; pdftohtml -q -stdout %s | w3m -T text/html; copiousoutput 
# application/msword; wvWare -x /usr/lib/wv/wvHtml.xml %s 2>/dev/null | w3m -T text/html; 
# copiousoutput 
# 
 
# 发件箱显示to subject date 邮件 
folder-hook . "ignore *; unignore from subject X-mailer date" 
folder-hook sent.* "ignore *; unignore to subject date" 
# 邮件头显示顺序 
hdr_order from to subject date 
 
folder-hook . 'macro index d ~/mail/trash\r' 
folder-hook mail/trash 'bind index d delete-message' 
 
 
ignore * 
unignore From: To: Reply-To: Newsgroups: Followup-to: Subject: Date: CC: BCC: X-Lable: Organization: 
hdr_order Subject: From: Date: To: CC: BCC: Reply-To: Newsgroups: Followup-to: X-Lable: Organization: 
alternative_order text/plain
# .mutt.alias 
alias zcj163 zcj163 <zhaochunjie.love@163.com> 
alias zcjoutlook zcjoutlook <zhaochunjie.love@outlook.com> 
alias zcjaliyun zcjaliyun <zhaochunjie@sourcod.com> 
alias zcjgmail zcjgmail <zhaochunjie@gmail.com>

配置msmtp

  1. 安装msmtp
  2. 配置.msmtprc
# Set default values for all following accounts. 
defaults 
logfile ~/mail/log/msmtp.log 
 
# gmail 
account gmail 
host smtp.gmail.com 
port 587 
protocol smtp 
auth login 
from zhaochj521@gmail.com 
user zhaochj521@gmail.com 
password ******** 
tls on 
tls_starttls on 
 
 
# 163 
account default 
host smtp.163.com 
from zhaochunjie.love@163.com 
auth login 
port 25 
user zhaochunjie.love@163.com 
password ******** 
logfile ~/mail/log/msmtp.log 
tls off 
 
# Set a default account 
 
account sourcod 
host smtp.mxhichina.com 
port 25 
from zhaochunjie@sourcod.com 
auth login 
user zhaochunjie@sourcod.com 
password ******** 
logfile ~/mail/log/msmtp.log 
tls off

配置fetchmail定时收邮件

  1. 安装fetchmail
    brew install fetchmail
  2. 配置.fetchmailrc
#set daemon 60 
defaults 
mda "/usr/local/bin/procmail -d %T" 
 
poll pop3.163.com 
proto pop3 
port 995 
user "zhaochunjie.love@163.com" 
password "********" 
is sourcod here 
no keep 
#options 
ssl 
sslcertck 
 
 
poll pop3.mxhichina.com 
proto pop3 
port 995 
user "zhaochunjie@sourcod.com" 
password "********" 
is sourcod here 
keep 
#options 
ssl 
sslcertck

效果:
mutt截图
内容
现在就可以收发邮件了。
是不是很高大上。


发布评论
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

Shell 实现多任务并发知识解答
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。