Chinaunix首页 | 论坛 | 博客
  • 博客访问: 143790
  • 博文数量: 19
  • 博客积分: 230
  • 博客等级: 二等列兵
  • 技术积分: 239
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-01 12:47
文章分类
文章存档

2014年(5)

2013年(4)

2012年(10)

分类: LINUX

2012-11-24 21:47:58

都说mutt方便,稳定,是基于命令行的。但是可能需要一定的配置,开始自己也不确定能否成功,就尝试了一次。详细mutt的说明就问问百度什么的(谷歌总被封)。
我用的是getmail+mutt+sendmail,因为这个搜索到的比较多。fetchmail postfix其它的网上也有,我也没弄,个人还是有点懒惰的:P  直接来配置文件(都在/home/ydjx下)
第一次进入mutt会自动建立一个Mail的文件夹,然后需要自己建立几个文件夹inbox postponed sent,inbox里还有cur tmp new  (这个是按照那个getmail那配置的Maildir来的 之前看过还有其它的类型但不记得了)
.muttrc  从别的地方抄来的 (我的环境语言是utf8的)

点击(此处)折叠或打开

  1. #
  2. # System configuration file for Mutt
  3. #
  4. #
  5. # default list of header fields to weed when displaying
  6. #
  7. ignore "from " received content- mime-version status x-status message-id
  8. ignore sender references return-path lines
  9. ignore date delivered-to precedence errors-to in-reply-to user-agent
  10. ignore x-loop x-sender x-mailer x-msmail-priority x-mimeole x-ms- x-priority
  11. ignore x-accept-language x-authentication-warning thread- priority importance
  12. ignore x-original-to domainkey-signature dkim-signature
  13. #
  14. # emacs-like bindings
  15. bind editor "\e" kill-word
  16. bind editor "\e" kill-word
  17. #
  18. # map delete-char to a sane value
  19. bind editor delete-char
  20. #
  21. # some people actually like these settings
  22. #set pager_stop
  23. #bind pager previous-line
  24. #bind pager next-line
  25. #
  26. # don't add the hostname to the From header
  27. unset use_domain
  28. # don't generate a From header
  29. unset use_from
  30. #
  31. # Specifies how to sort messages in the index menu.
  32. set sort=threads
  33. #
  34. # Exim does not remove Bcc headers
  35. unset write_bcc
  36. # Postfix and qmail use Delivered-To for detecting loops
  37. unset bounce_delivered
  38. #
  39. # weed out binary-only announcements to -devel-changes
  40. #macro index \CW T!~s\(.*source.*\)\nWn^T~A\n "Weed out binary-only announcements"
  41. #
  42. # imitate the old search-body function
  43. macro index \eb "~b " "search in message bodies"
  44. #
  45. # simulate the old url menu
  46. macro index,pager \cb " urlview" "call urlview to extract URLs out of a message"
  47. macro attach,compose \cb " urlview" "call urlview to extract URLs out of a message"
  48. #
  49. # Show documentation when pressing F1
  50. macro generic "!zcat /usr/share/doc/mutt/manual.txt.gz | sensible-pager\n" "Show Mutt documentation"
  51. macro index "!zcat /usr/share/doc/mutt/manual.txt.gz | sensible-pager\n" "Show Mutt documentation"
  52. macro pager "!zcat /usr/share/doc/mutt/manual.txt.gz | sensible-pager\n" "Show Mutt documentation"
  53. #
  54. # Use folders which match on \\.gz$ or \\.bz2$ as [gb]zipped folders:
  55. open-hook \\.gz$ "gzip -cd %f > %t"
  56. close-hook \\.gz$ "gzip -c %t > %f"
  57. append-hook \\.gz$ "gzip -c %t >> %f"
  58. open-hook \\.bz2$ "bzip2 -cd %f > %t"
  59. close-hook \\.bz2$ "bzip2 -c %t > %f"
  60. append-hook \\.bz2$ "bzip2 -c %t >> %f"
  61. #
  62. # show the incoming mailboxes list (just like "mutt -y") and back when pressing "y"
  63. macro index,pager y "?" "show incoming mailboxes list"
  64. bind browser y exit
  65. #
  66. # If Mutt is unable to determine your site's domain name correctly, you can
  67. # set the default here.
  68. #
  69. # set hostname=cs.hmc.edu
  70. #
  71. # If your sendmail supports the -B8BITMIME flag, enable the following
  72. #
  73. # set use_8bitmime
  74. #
  75. ##
  76. ## *** DEFAULT SETTINGS FOR THE ATTACHMENTS PATCH ***
  77. ##
  78. #
  79. ##
  80. ## Please see the manual (section "attachments") for detailed
  81. ## documentation of the "attachments" command.
  82. ##
  83. ## Removing a pattern from a list removes that pattern literally. It
  84. ## does not remove any type matching the pattern.
  85. ##
  86. ## attachments +A */.*
  87. ## attachments +A image/jpeg
  88. ## unattachments +A */.*
  89. ##
  90. ## This leaves "attached" image/jpeg files on the allowed attachments
  91. ## list. It does not remove all items, as you might expect, because the
  92. ## second */.* is not a matching expression at this time.
  93. ##
  94. ## Remember: "unattachments" only undoes what "attachments" has done!
  95. ## It does not trigger any matching on actual messages.
  96. #
  97. ## Qualify any MIME part with an "attachment" disposition, EXCEPT for
  98. ## text/x-vcard and application/pgp parts. (PGP parts are already known
  99. ## to mutt, and can be searched for with ~g, ~G, and ~k.)
  100. ##
  101. ## I've added x-pkcs7 to this, since it functions (for S/MIME)
  102. ## analogously to PGP signature attachments. S/MIME isn't supported
  103. ## in a stock mutt build, but we can still treat it specially here.
  104. ##
  105. attachments +A */.*
  106. attachments -A text/x-vcard application/pgp.*
  107. attachments -A application/x-pkcs7-.*
  108. #
  109. ## Discount all MIME parts with an "inline" disposition, unless they're
  110. ## text/plain. (Why inline a text/plain part unless it's external to the
  111. ## message flow?)
  112. ##
  113. attachments +I text/plain
  114. #
  115. ## These two lines make Mutt qualify MIME containers. (So, for example,
  116. ## a message/rfc822 forward will count as an attachment.) The first
  117. ## line is unnecessary if you already have "attach-allow */.*", of
  118. ## course. These are off by default! The MIME elements contained
  119. ## within a message/* or multipart/* are still examined, even if the
  120. ## containers themseves don't qualify.
  121. ##
  122. #attachments +A message/.* multipart/.*
  123. #attachments +I message/.* multipart/.*
  124. #
  125. ## You probably don't really care to know about deleted attachments.
  126. attachments -A message/external-body
  127. attachments -I message/external-body
  128. #
  129. # colors
  130. color normal white black
  131. color attachment brightyellow black
  132. color hdrdefault cyan black
  133. color indicator black cyan
  134. color markers brightred black
  135. color quoted green black
  136. color signature cyan black
  137. color status brightgreen blue
  138. color tilde blue black
  139. color tree red black
  140. #color header brightgreen black ^From:
  141. #color header brightcyan black ^To:
  142. #color header brightcyan black ^Reply-To:
  143. #color header brightcyan black ^Cc:
  144. #color header brightblue black ^Subject:
  145. #color body brightred black [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+
  146. #color body brightblue black (https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+
  147. #
  148. # GnuPG configuration
  149. set pgp_decode_command="gpg --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
  150. set pgp_verify_command="gpg --status-fd=2 --no-verbose --quiet --batch --output - --verify %s %f"
  151. set pgp_decrypt_command="gpg --status-fd=2 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
  152. set pgp_sign_command="gpg --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --detach-sign --textmode %?a?-u %a? %f"
  153. set pgp_clearsign_command="gpg --no-verbose --batch --quiet --output - %?p?--passphrase-fd 0? --armor --textmode --clearsign %?a?-u %a? %f"
  154. set pgp_encrypt_only_command="/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
  155. set pgp_encrypt_sign_command="/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
  156. set pgp_import_command="gpg --no-verbose --import %f"
  157. set pgp_export_command="gpg --no-verbose --export --armor %r"
  158. set pgp_verify_key_command="gpg --verbose --batch --fingerprint --check-sigs %r"
  159. set pgp_list_pubring_command="gpg --no-verbose --batch --quiet --with-colons --list-keys %r"
  160. set pgp_list_secring_command="gpg --no-verbose --batch --quiet --with-colons --list-secret-keys %r"
  161. set pgp_good_sign="^\\[GNUPG:\\] GOODSIG"
  162. #
  163. # S/MIME configuration
  164. set smime_ca_location="~/.smime/ca-bundle.crt"
  165. set smime_certificates="~/.smime/certificates"
  166. set smime_keys="~/.smime/keys"
  167. set smime_pk7out_command="openssl smime -verify -in %f -noverify -pk7out"
  168. set smime_get_cert_command="openssl pkcs7 -print_certs -in %f"
  169. set smime_get_signer_cert_command="openssl smime -verify -in %f -noverify -signer %c -out /dev/null"
  170. set smime_get_cert_email_command="openssl x509 -in %f -noout -email"
  171. set smime_import_cert_command="smime_keys add_cert %f"
  172. set smime_encrypt_command="openssl smime -encrypt %a -outform DER -in %f %c"
  173. set smime_sign_command="openssl smime -sign -signer %c -inkey %k -passin stdin -in %f -certfile %i -outform DER"
  174. # This alternative command does not include the full certificates chain.
  175. # Be sure to understand RFC 2315 section 9.1 before using it.
  176. # set smime_sign_command="openssl smime -sign -signer %c -inkey %k -passin stdin -in %f -outform DER"
  177. set smime_decrypt_command="openssl smime -decrypt -passin stdin -inform DER -in %f -inkey %k -recip %c"
  178. set smime_verify_command="openssl smime -verify -inform DER -in %s %C -content %f"
  179. set smime_verify_opaque_command="openssl smime -verify -inform DER -in %s %C"
  180. #
  181. set mixmaster="mixmaster-filter"
  182. #
  183. # See /usr/share/doc/mutt/README.Debian for details.
  184. source /usr/lib/mutt/source-muttrc.d|
  185. #
  186. #以下是自定义项
  187. #
  188. #收信设置,使用fetchmail收信的时候将下面注释符号去掉半作相应修改,本次使用getmail故此处保持注释状态
  189. #set pop_last=yes
  190. #set pop_pass=【相应Gmail邮箱密码】
  191. #set pop_user=【邮箱账号】@gmail.com
  192. #set pop_host=pops://pop.gmail.com
  193. #
  194. #颜色设置
  195. color normal brightblue default
  196. color attachment blue default
  197. color error red white
  198. color status white blue
  199. color hdrdefault magenta default
  200. color indicator black cyan
  201. #
  202. #发信设置
  203. set sendmail="/usr/bin/msmtp"
  204. set use_from=yes
  205. set from= 我的邮箱@gmail.com
  206. set envelope_from=yes
  207. #
  208. #设置默认编辑器
  209. set editor="vim"
  210. #设置信箱
  211. set mbox="~/Mail/inbox"
  212. set mbox_type=Maildir
  213. set spoolfile="~/Mail/inboxrc"
  214. set postponed="~/Mail/postponed"
  215. set record="~/Mail/sent"
  216. #
  217. macro index G "!getmail\n" "Invoke getmail"
  218. macro pager G "!getmail\n" "Invoke getmail"
  219. #
  220. # 让mutt监视下面几个邮箱,并随时报告新邮件
  221. # mailboxes "=inbox"
  222. # mailboxes "=USTCstudent"
  223. # mailboxes "=USTCteacher"
  224. # mailboxes "=ustcbbs
  225. # mailboxes "=Gmail"
  226. # set check_new = yes
  227. # set timeout = 600
  228. #
  229. #set alternates=" usr@gmail.com"
  230. ## 这是一个格式字符串,用来控制你的index的列表显示。它的缺省定义是
  231. ## set index_format="%4C %Z %{%b %d} %-15.15L (%4l) %s"
  232. ##指定你有哪 些信箱文件。当你按 "c" 切换信箱时,再按 Tab 键,这些信箱就可供你选择
  233. mailboxes Mailbox sent-mail
  234. ## 这是一个 bool 型变量。它表明你在回信时引用原文是否加入原文的邮件头。
  235. set header=yes
  236. ## 可以设置为 yes, no, ask-yes, 或者 ask-no.
  237. ## 这是说,当你按q退出时,是否提示你(ask-yes,ask-no),
  238. ## 还是直接就退出了(yes),还是根本不理你(no)。
  239. #set quit=ask-yes
  240. ## 那些类型的附件是允许直接通过 .mailcap 浏览的?
  241. #doc类型的附件通过wvware转成html 浏览
  242. auto_view text/html application/msword
  243. ## 这也是一个提示性变量。它是确定当你退出时,是否提示你把信件
  244. ##从spool 移动到的mbox 文件。
  245. set move=no
  246. ## 当 Mutt 用 thread 方式显示时,是否用纯 ascii 表示树状列表。
  247. set ascii_chars=yes
  248. ## 回信时是否包含原文。
  249. set include
  250. ## 回信的引文之前插入那个符号?
  251. set indent_str="> "
  252. ## 设置你自己的邮件头。
  253. my_hdr From: 我想显示的邮箱@gmail.com
  254. ## 打分
  255. ## 新信件+4分,主题包含"通知"的+2,主题包含 "Circulation" +3, 已经标记
  256. ## 删除的 -5,上次没有读的 +1,包含 "believe"的 -10(垃圾广告!)。
  257. score "~N" +4
  258. score "~s 通知" +2
  259. score "~s icesx" +3
  260. score "~D" -5
  261. score "~O" +1
  262. score "~s believe" -10
  263. ## 排序方式。
  264. set sort=score
  265. ## 当用 thread 排序方式时,我们对各个 thread 的相对排序顺序。
  266. set sort_aux=date
  267. ## 如果翻到最后,再按往下翻也不会翻到下一封信件
  268. set pager_stop
  269. ## 如果设置,当你按 "r"
  270. ## 回信时,就不会再提示你输入回信地址和主题,直接进入编辑
  271. ##模式。
  272. set fast_reply
  273. ## 当你按 "t" 或者 "D" 之类的标记操作时,是否自动把光标移动到下一封信件。
  274. set resolve=yes
  275. ## 地址簿
  276. source ~/.mutt.alias
  277. ## 当你在 index 里按 "a"
  278. ## 为来信者取别名时,使用哪一个别名文件保存这个别名。
  279. set alias_file=/home/ydjx/.mutt.alias
  280. ## 你发出的邮件保存到那个信箱文件?比如可以像我这样每个月发出的信件放在不同的文件
  281. #里。
  282. set record="~/Mail/=sent-mail-`date +%Y-%m`"
  283. ## 你的终端支持哪一种编码的显示?这个必须和你的终端编码一样。
  284. ##注意这个如果设置不正确的话会导致在写邮件时出现一个"bad IDN"的错误信息
  285. set charset="utf-8"
  286. ## send_charset
  287. set send_charset="us-ascii:iso-8859-1:gb2312:utf-8"
  288. ## 外部程序退出时,是否要求用户按一个键才返回。这在察看某些shell命令输出时是比要>的,
  289. ## 否则它们一下就消失了。
  290. set wait_key=yes
  291. ## 当你要把信件存到另一个信箱,而这个信箱已经存在时,是否提示附加?
  292. set noconfirmappend
  293. ## 是否把邮件头也放在编辑器里可以修改?
  294. set edit_headers=no
  295. ## 当你在用 pager 看信件时,在 index 留出多少行显示邮件列表?
  296. set pager_index_lines=4
  297. ## 告诉 Mutt 你已经订阅了那些邮件列表(mailing-list).
  298. ## subscribe fvwm@fvwm.org
  299. ## mutt显示日期为中文
  300. ##set locale="zh_CN"
  301. set locale="UTF-8"
  302. ## Chinaren 等服务器发出来的信件使用了 quoted-printable 的 subject,
  303. ## 而且设置编码为 "iso8859-1",这显然是错误的。
  304. ## 对付这个错误的办法是把 iso-8859-1 变成 gb2312 的别名
  305. charset-hook ^iso-8859-1$ gb2312
  306. ## evolution 发过来的 subject 为 utf-8 编码的邮件标题乱码!
  307. ## 那就把不是 utf-8 的编码都映射到 gb2312
  308. charset-hook !utf-8 gb2312
  309. ##删除到Trash目录
  310. folder-hook . 'macro index d "~/Mail/Trash\r"'
  311. folder-hook ~/Mail/Trash 'bind index d delete-message'
  312. ##签名档
  313. set signature="~/Mail/.signature"

getmailrc 用来收邮件,权限要设置为700 就是只给执行权限,此文件放在了.getmail文件夹中
gmail的pop3/imap强制使用ssl连接,一般的不需要的或者不支持的就需要去掉type中的ssl

点击(此处)折叠或打开

  1. [options]
  2. verbose=1
  3. read_all=false
  4. delete=false
  5. message_log=~/.getmail/log

  6. [retriever]
  7. type=SimplePOP3SSLRetriever
  8. server=pop.gmail.com
  9. port=995
  10. username=我的邮箱@gmail.com
  11. password=我的密码

  12. [destination]
  13. type=Maildir
  14. path=~/Mail/inbox/
.msmtprc 用来发送邮件,权限为600 因为这里有密码所以不允许高权限,否则会警告的

点击(此处)折叠或打开

  1. account ShouHuXinYang
  2. host smtp.gmail.com
  3. from ShouHuXinYang@gmail.com
  4. auth on
  5. user ShouHuXinYang@gmail.com
  6. password 我的密码
  7. port 587
  8. tls on
  9. tls_starttls on
  10. tls_trust_file /etc/ssl/certs/ca-certificates.crt


  11. account default:ShouHuXinYang
证书验证文件是下载的wget
折腾这么多原理就 用各自专业的东西干各自的事情,mutt管理邮件,fetchmail getmail 用来收邮件,sendmail postfix用来发邮件
G 用来收邮件  c ? 进入邮箱邮件列表 m 发送邮件 r回复邮件 签名通讯录什么的就看配置吧

参考

http://blog.chinaunix.net/uid-20543672-id-3349607.html 参考

其实参考的比较多 我也不能都记录下来了,在此谢过那些分享人们了~~


遗留问题:我这里还有一个问题 就是如果我想根据不同的邮箱 用不同的帐户发出去 我就不知道怎么设置了,之前见过有人自己定一个宏,还说有点小问题,我也没细看,现在不知道有没有好的办法?


阅读(9896) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~