mutt with gmail

需要的程序:

getmail:pop3邮件收取程序,从服务器拉邮件下来是他的事情。

Homepage: http://pyropus.ca/software/getmail/
Description: A POP3 mail retriever with reliable Maildir and mbox delivery

procmail:邮件分类工具getmail收取过来的邮件经过他的分类存储在硬盘当中。

Homepage: http://www.procmail.org/
Description: Mail delivery agent/filter

msmtp:发送邮件的工具使用smtp协议

Homepage: http://memberwebs.com/nielsen/software/clamsmtp/
Description: ClamSMTP is an SMTP filter that allows you to check for viruses using the ClamAV anti-virus software

mutt:主角登场。mutt在这里主要是用来阅读邮件作为上面三者的用户界面来使用

Homepage: http://www.mutt.org/
Description: A small but very powerful text-based mail client

配置:

getmail

存放到~/.getmail/getmailrc.gmail

?View Code GETMAILRC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[options]
verbose  = 0
read_all = false
delete = true
[retriever]
type     = SimplePOP3SSLRetriever
server   = pop.gmail.com
port     = 995
username = 用户名(gmail的用户名是完成的邮箱包括@gmail.com)
password = 密码
[destination]
type     = MDA_external
path     = /usr/bin/procmail
unixfrom = true

再做个脚本来获取邮件存储成gmail.sh放到自己方便的位置就Ok

1
2
# !/bin/bash
getmail -n -r ~/.getmail/getmailrc.gmail

procmail

配置文件存放在~/.procmailrc
相关的文件夹自己建立

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
MAILDIR = $HOME/mail
DEFAULT = $MAILDIR/inbox
LOGFILE = $MAILDIR/procmaillog
 
#过滤规则
#没行以:0开头
#接下来*开头跟匹配的正则表达式
#最后为放入的文件
#例如如下过滤所有邮件来自gentoo中文用户组的邮件放入gentoo-cn
:0
* ^List-Id:.*gentoo-china.googlegroups.com
gentoo-cn
 
#默认情况放入inbox
:0
* .* inbox
default

msmtp

放到~/,msmtprc中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
defaults
logfile ~/.msmtp.log
# gmail account
account gmail
auth on
host smtp.gmail.com
port 587
user 用户名(gmail的用户名是完成的邮箱包括@gmail.com)
password 密码
from 邮箱
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# set default account to use (from above)
account default : gmail

mutt的配置在接下来的大节中描述

mutt

muttrc

主要配置文件放入~/.muttrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
set folder="~/mail"
set mbox      = "~/mail/inbox"    # 收件箱文件
set record    = "~/mail/sent"     # 发件箱文件
set spoolfile = "~/mail/inbox"    # 启动mutt后默认显示的信箱文件
set alias_file= "~/mail/addressbook"#地址本
mailboxes = ~/mail/gentoo-cn      #监控的邮件分类如果此邮件分类有邮件会在mutt最下方显示
set charset      = "utf-8"           # 终端支持的编码,Linux下一般是utf8
set send_charset = "utf-8"           # 发信编码
charset-hook ^us-ascii$ gb2312       # 用gb2312编码显示未设置编码的信件
charset-hook ^big5$ big5             # 用big5编码显示繁体信件
charset-hook !utf-8 gb2312           # 用gb2312编码显示非utf-8编码的信件
set assumed_charset    = "gb2312"    # 用gb2312编码显示未经MIME编码的信件
set indent_str="> "                 # 回信引文之前的符号
set include=yes                       # 回信时自动包含原文
# 自动显示
auto_view text/
auto_view text/html
# mutt用纯ascii表示树状列表
set ascii_chars=yes
set confirmappend=no
set use_envelope_from=yes
#
set use_from = yes
set envelope_from = yes
set check_new = yes
set timeout = 600
set editor =  'emacs -nw' #指定编辑器
set sort = 'threads'
set sort_aux = 'last-date-received'
hdr_order Date From To Cc
set wait_key=yes
set rfc2047_parameters = yes
set sendmail  = "/usr/bin/msmtp"
#mutt自带pop3收信。但是我们采用getmail来收信以便procmail进行分类
#以下是自带pop3配置
set pop_user= 用户名(gmail的用户名是完成的邮箱包括@gmail.com)
set pop_pass= 密码
set pop_host=pops://pop.gmail.com
set pop_last=yes
 
set realname = "名字"
set from     = "邮箱例如 Tester "
set use_from = yes
source ~/.mutt/muttcolor
source ~/.mutt/keydef
source ~/.mutt/maillist

其他配置

还有三个文件可以根据自己爱好来设置分别为
mutt颜色设置 ~/.mutt/muttcolor
mutt按键绑定 ~/.mutt/keydef
mutt邮件列表指示 ~/.mutt/maillist

muttcolor

主要是相关颜色配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#---- Mutt Colors for White Background -------
color    hdrdefault    black           default
color    quoted        red             default
color    signature     brightblack     default
color    indicator     brightwhite     red
color    attachment    black           default
color    error         red             default
color    message       blue            default
color    search        brightwhite     magenta
color    status        brightyellow    blue
color    tree          red             default
color    normal        blue            default
color    tilde         green           default
color    bold          brightyellow    default
color    markers       red             default

maillist

订阅的邮件列表。告诉mutt哪些当成邮件列表处理。
发自这些列表的邮件Mutt界面会有L标记。回复的时候按L回复到邮件列表(按R就回复到发那封邮件的个人的手中了)

1
2
3
4
5
6
7
8
9
subscribe linux-kernel.vger.kernel.org
subscribe kernel-janitors.vger.kernel.org
subscribe python-cn.googlegroups.com
subscribe gentoo-china.googlegroups.com
subscribe linux-kernel.vger.kernel.org
subscribe gentoo-user.gentoo.org
subscribe gentoo-dev.gentoo.org
subscribe gentoo-amd64.gentoo.org
subscribe gentoo-announce.gentoo.org

keydef

按键绑定。这里很简单。我设置的仅仅是按I调用外部的getmail收取邮件

1
macro index,pager I '~/.getmail/getmail.sh'
----------------- 全文结束 -----------------
© 该日志作者:Senghoo, 于2011年12月13日发表于分类"Using Linux"下;
© 除非另有注明本文采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议进行许可。
© 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
© 转载请注明: mutt with gmail | 转自: Senghoo's Blog
© Tag: , , , , ,

随机日志

  • LDD读书笔记第一章-设备驱动程序简介
    第一章介绍性的东西。 没有什么知识点。 上传ldd3(linux device drivers 3)的全部配套源码 Linux Device Drivers, Third Edition Source Code ...
  • 开源协议的选择
    看到阮一峰发飙了一个图片关于开源协议的选择。 http://www.ruanyifeng.com/blog/2011/05/how_to_choose_free_software_licenses.html 很简单明了,有助于选择的同时也有助于理解不同协议的不同之处。 ...

发表评论