emacs 用作邮件工具,咋配置?
Posted 我有一腔沉默寡言
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了emacs 用作邮件工具,咋配置?相关的知识,希望对你有一定的参考价值。
目录
1. offlineimap
1.1. 安装
1.2. 配置
1.3. 运行(按配置拉取邮件到本地)
2. mu
2.1. 安装
2.2. Emacs 配置
使用 offlineimap 来收邮件,使用 mu(mu4e)来管理邮件。即可。
1 offlineimap
使用 offlineimap 通过 imap(不支持 pop3 协议)协议从邮件服务器下载邮件到本地,并按照 maildir 格式存储在本地磁盘。
官网: http://www.offlineimap.org/
1.1 安装
sudo pacman -Sy offlineimap
1.2 配置
配置文件位置存放:~/.offlineimaprc
配置样例:http://cachestocaches.com/2017/3/complete-guide-email-emacs-using-mu-and-/
配置参数说明:https://github.com/OfflineIMAP/offlineimap/blob/master/offlineimap.conf
配置文件样例:
[general]
# List of accounts to be synced, separated by a comma.
accounts = act1, act2
# accounts = act1
maxsyncaccounts = 1
[Account act1]
# Identifier for the local repository; e.g. the maildir to be synced via IMAP.
localrepository = act1
# Identifier for the remote repository; i.e. the actual IMAP, usually non-local.
remoterepository = act1@163
postsynchook = mu index --maildir ~/.offlineimap/mail
[Repository act1]
# OfflineIMAP supports Maildir, GmailMaildir, and IMAP for local repositories.
type = Maildir
# Where should the mail be placed?
localfolders = ~/.offlineimap/mail/act1
[Repository act1@163]
# Remote repos can be IMAP or Gmail, the latter being a preconfigured IMAP.
type = IMAP
remotehost = imap.163.com
remoteuser = act1
remotepass = password
starttls = yes
ssl = yes
sslcacertfile = OS-DEFAULT
[Account act2]
localrepository = act2
remoterepository = act2.remote
postsynchook = mu index --maildir /apt/act2mail
[Repository act2]
type = Maildir
# Where should the mail be placed?
localfolders = /apt/act2mail
[Repository act2.remote]
# Remote repos can be IMAP or Gmail, the latter being a preconfigured IMAP.
type = IMAP
remotehost = imap.xxxx.com.cn
remoteuser = act2
remotepass = password2
starttls = yes
ssl = no
# sslcacertfile = OS-DEFAULT
1.3 运行(按配置拉取邮件到本地)
# 在 shell 中执行
offlineimap
2 mu
"mu is a tool for dealing with e-mail messages stored in the Maildir-format, on Unix-like systems. mu’s main purpose is to help you to find the messages you need, quickly; in addition, it allows you to view messages, extract attachments, create new maildirs,"
官网:http://www.djcbsoftware.nl/code/mu/
mu 附带提供 mu4e,使得可以方便使用 Emacs 来管理邮件。
2.1 安装
cd ~/installed
git clone https://aur.archlinux.org/mu.git
cd mu
makepkg -si
# 安装之后,mu4e 被自动安装到 /usr/share/emacs/site-packages 中
2.2 Emacs 配置
需要在 Emacs 配置文件(~/.emacs)中进行适当配置才能正常使用 mu4e。
详细的配置指引参见 Emacs 内置 info 的 :Getting Started 章节。
配置样例:
(require 'mu4e)
(require 'org-mu4e)
;; use mu4e for e-mail in emacs
(setq mail-user-agent 'mu4e-user-agent)
;; Only needed if your maildir is _not_ ~/Maildir
;; Must be a real dir, not a symlink
;; (setq mu4e-maildir "/home/jng/.offlineimap/mail")
;; these must start with a "/", and must exist
;; (i.e.. /home/user/Maildir/sent must exist)
;; you use e.g. 'mu mkdir' to make the Maildirs if they don't
;; already exist
;; below are the defaults; if they do not exist yet, mu4e offers to
;; create them. they can also functions; see their docstrings.
;; (setq mu4e-sent-folder "/sent")
;; (setq mu4e-drafts-folder "/drafts")
;; (setq mu4e-trash-folder "/trash")
(setq
mu4e-get-mail-command "offlineimap" ;; or fetchmail, or ...
mu4e-update-interval 300) ;; update every 5 minutes
;; smtp mail setting; these are the same that `gnus' uses.
(setq
message-send-mail-function 'smtpmail-send-it
)
;; 增加 search query:显示 flagged 的邮件
(add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark
:name "flagged messages"
:query "flag:flagged"
:key ?f))
(add-to-list 'mu4e-bookmarks
(make-mu4e-bookmark
:name "trashed messages"
:query "flag:trashed"
:key ?T))
(setq mu4e-contexts
`( ,(make-mu4e-context
:name "work"
:enter-func (lambda () (mu4e-message "Entering WORK context"))
:leave-func (lambda () (mu4e-message "Leaving WORK context"))
;; we match based on the contact-fields of the message
:match-func (lambda (msg)
(when msg
(mu4e-message-contact-field-matches msg
:to "act2@xxxx.com.cn")))
:vars '( ( user-mail-address . "act2@xxxx.com.cn" )
( user-full-name . "zhangsanlisi" )
( smtpmail-smtp-server . "smtp.xxxx.com.cn")
( mu4e-maildir . "/apt/xxxxmail")
( mu4e-attachment-dir . "/home/xxxx/Downloads/mailAttachment/work")
( mu4e-compose-signature .
(concat
"姓名\n"
"签名 | e: act2@xxxx.com.cn | life is short, use Python and Emacs ! \n"))))
,(make-mu4e-context
:name "act1"
:enter-func (lambda () (mu4e-message "Switch to the ACT1 context"))
;; no leave-func
;; we match based on the maildir of the message
;; this matches maildir /Arkham and its sub-directories
:match-func (lambda (msg)
(when msg
(mu4e-message-contact-field-matches msg
:to "act1@163.com")))
:vars '( ( user-mail-address . "act1@163.com" )
( user-full-name . "act1" )
( smtpmail-smtp-server . "smtp.163.com")
( mu4e-maildir . "/home/jng/.offlineimap/mail")
( mu4e-attachment-dir . "/home/jng/Downloads/mailAttachment/act1")
( mu4e-compose-signature .
(concat
"xxx\n"
"yyy. zzz\n"))))))
Author: 祺嘉爸
Created: 2019-09-12 15:09:18
Edited using: Emacs
Exported using: customized-html-backend
以上是关于emacs 用作邮件工具,咋配置?的主要内容,如果未能解决你的问题,请参考以下文章