zeissoctopus 发表于 2012-05-20 01:14

Mew 邮件阅读 gmail imap 笔记

本帖最后由 zeissoctopus 于 2012-05-20 01:19 编辑

安装流程
mew 是 emacs 一个 lisp 邮件阅读器,若使用她存取 gmail imap 户口,由于她不支援 OpenSSL 命令,需倚赖 stunnel 做 SSL 中介。令 mew 舒适阅览 html 电邮,也需要安装 emacs-w3m 套件。本文假设已安装好 emacs。

1: 安装 ca_root_nss
存取 gmail 服务需要 ca root 认証书,安装 ca_root_nss 可以取得之
% cd /usr/ports/security/ca_root_nss
% su root
# make config
# make install
# make clean
# exit
我安装 ca_root_nss 时使用的 ports 选项
FORKETCSYMLINK=YES

2: 安装 stunnel

i) 安装 stunnel
从 ports 安装 stunnel
% cd /usr/ports/security/stunnel
% su root
# make config
# make install
# make clean
# exit
我安装 stunnel 时使用的 ports 选项
FORK=NO
PTHREAD=YES            
UCONTEXT=NO   
IPV6=NO      
LIBWRAP=YES
SSL_PORT=YES               

ii) 产生认证 pem 文件
% cd /usr/local/etc/stunnel
% su root
# cp /usr/src/crypto/openssl/certs/demo/ca-cert.pem ./stunnel.pem
# dd if=/dev/urandom count=2 | openssl dhparam -rand - 1024 >> ./stunnel.pem
# exit
iii) 配置 /usr/local/etc/stunnel/stunnel.conf 设定文件

设定 stunnel 服务引导 Gmail IMAP, Gmail SMTP
; **************************************************************************
; * Global options                                                         *
; **************************************************************************
chroot = /var/run/stunnel
setuid = stunnel
setgid = stunnel

; PID is created inside the chroot jail
pid = /stunnel.pid

; Debugging stuff (may useful for troubleshooting)
;debug = 7
output = stunnel.log

; **************************************************************************
; * Service defaults may also be specified in individual service sections*
; **************************************************************************

; Certificate/key is needed in server mode and optional in client mode
cert = /usr/local/etc/stunnel/stunnel.pem

; Disable support for insecure SSLv2 protocol
options = NO_SSLv2
sslVersion = SSLv3

; **************************************************************************
; * Service definitions (remove all services for inetd mode)               *
; **************************************************************************

client = yes
accept = 127.0.0.1:54587
connect = smtp.gmail.com:587


client = yes
accept = 127.0.0.1:59939
connect = imap.gmail.com:993
iv) 启动 stunnel 服务
增加以下一行到 /etc/rc.conf,下次重新启动 FreeBSD 便自动载入
stunnel_enable="YES"
立即启动 stunnel 服务,请输入以下命令
% su -
# service stunnel start
# exit
3: 安装 emacs-w3m
% cd /usr/ports/www/emacs-w3m
% su root
# make install
# make clean
# exit
安装 emacs-w3m 时会倚赖一并安装 www/w3m 以下是我安装 w3m 时的 ports 选项
M17N=YES
JAPANESE=NO
INLINE_IMAGE=YES
KEY_LYNX=NO

4: 安装 Mew

i) 从 ports 安装 Mew
从 ports 安装 mew
% cd /usr/ports/mail/mew
% su root
# make config
# make install
# make clean
# exit
我安装 mew 时使用的 ports 选项
DATABASE=YES

ii) 配置 .emacs
修改 $HOME/.emacs 加入 mew 邮件阅读器入 emacs,并设定一些环境
;;
;; coding setting
(setq locate-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;;
;; emacs-w3m
(autoload 'w3m "w3m" "Interface for w3m on Emacs." t)
;;
;; Mew
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
;; Mew Options
(setq read-mail-command 'mew)
(autoload 'mew-user-agent-compose "mew" nil t)
(if (boundp 'mail-user-agent)
    (setq mail-user-agent 'mew-user-agent))
(if (fboundp 'define-mail-user-agent)
    (define-mail-user-agent
       'mew-user-agent
       'mew-user-agent-compose
       'mew-draft-sent-message
       'mew-draft-kill
       'mew-send-hook))
iii) 配置 .mew.el 使用 Gmail 帐号
修改 $HOME/.mew.el,把 emacs-w3m,fetch 功能加入 mew。引导 mew 使用 FreeBSD 的 ca-root-nss 套件中的証明书,并配置好 gmail imap 和 gmail smtp 服务。
;;
;; use emacs-w3m in Mew
(require 'mew-w3m)
(setq mew-prog-html '(mew-mime-text/html-w3m nil nil))
(setq mew-mime-multipart-alternative-list '("Text/Html" "Text/Plan" ".*"))
;;
;; using fetch for PGP instead of wget
(setq mew-prog-pgpkey "fetch")
(setq mew-prog-pgpkey-arg '("-q" "-o" "-"))
;;
;; SSL/TLS
(setq mew-config-alist
'(
    (default
       (ssl-cert-directory "\nCAfile=/usr/local/share/certs/ca-root-nss.crt")
       (proto "%")
       (name "你的名字")
       (user "你的 gmail 用户名")
       (mail-domain "gmail.com")
       (imap-server "imap.gmail.com")
       (imap-user "你的 gmail imap 用户名")
       (imap-auth t)
       (imap-ssl t)
       (imap-ssl-port 993)
       (imap-delete n)
       (imap-header-only t)
       (imap-inbox-folder "%Inbox")
       (imap-trash-folder "%Trash")
       (smtp-auth t)
       (smtp-ssl t)
       (smtp-ssl-port 587)
       (stmp-auth-list("PLAIN" "LOGIN" "CRAM-MD5"))
       (smtp-user "你的 gmail 用户名@gmail.com")
       (smtp-server "smtp.gmail.com")
    )
)
)
;;
;; Save password
(setq mew-use-cached-passwd t)
iv) 启动 mew 存取 Gmail 帐号
启动 emacs 后,键入 M-x mew 进入 mew 画面,接着输入 gmail 用户密码便成。
页: [1]
查看完整版本: Mew 邮件阅读 gmail imap 笔记