importjsonimportsubprocessdefsecure_string_for(account,service):# this relies on the macOS `security` toolreturnsubprocess.check_output(["security","find-internet-password","-a",account,"-s",service,"-w"]).strip()
$ offlineimap
OfflineIMAP 7.2.4
Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)
imaplib2 v2.57 (bundled), Python v2.7.16, OpenSSL 1.1.1d 10 Sep 2019
Account sync {USERNAME}@hotmail.com:
*** Processing account {USERNAME}@hotmail.com
Account sync {USERNAME}@hotmail.com:
*** Finished account '{USERNAME}@hotmail.com' in 31:41
\* mu4e - mu for emacs version 1.2.0 C
Basics
* [j]ump to some maildir
* enter a [s]earch query
* [C]ompose a new message
Bookmarks
* [bu] Unread messages
* [bt] Today's messages
* [bw] Last 7 days
* [bo] Last 1 days
* [bm] Last 1 days (org mode)
* [bs] sent
* [bd] drafts
* [bp] Messages with images
Misc
* [;]Switch context
* [U]pdate email & database
* [N]ews
* [A]bout mu4e
* [H]elp
* [q]uit
;; configure the bookmarks.(setqmu4e-bookmarks'(("flag:unread AND NOT flag:trashed""Unread messages"?u)("date:today..now""Today's messages"?t)("date:7d..now""Last 7 days"?w)("date:1d..now AND NOT list:emacs-orgmode.gnu.org""Last 1 days"?o)("date:1d..now AND list:emacs-orgmode.gnu.org""Last 1 days (org mode)"?m)("maildir:/sent""sent"?s)("maildir:/drafts""drafts"?d)("mime:image/*""Messages with images"?p)))
以上 Bookmarks 定义在 mu4e-main-view 显示如下:
1
2
3
4
5
6
7
8
9
10
Bookmarks
* [bu] Unread messages
* [bt] Today's messages
* [bw] Last 7 days
* [bo] Last 1 days
* [bm] Last 1 days (org mode)
* [bs] sent
* [bd] drafts
* [bp] Messages with images
;;store org-mode links to messages(require'org-mu4e);;store link to message if in header view, not to header query(setqorg-mu4e-link-query-in-headers-modenil)
并更新您的 org-capture 配置如下
1
2
3
(setqorg-capture-templates'(("t""todo"entry(file+headline"~/todo.org""Tasks")"* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")))
注意这个配置中 %a 配置的用途是添加一个链接到创建 capture 的来源。
美妙的是,现在可以在浏览邮件的时候,随时通过 C-c c t 为当前正在浏览的邮件创建一个待办事项,现在,您可以放心的归档邮件,因为您知道可以随时通过代办事项列表的链接打开该邮件。
;; 配置默认 smtp 服务以使用 smtpmail mode 发送 Email;; SMTP 服务需要认证,我们采用 ~/.authinfo.gpg 的方式提供认证信息。;; 有关 SMTP 认证, 参阅 https://www.emacswiki.org/emacs/SmtpAuth(setqsend-mail-function'smtpmail-send-itmessage-send-mail-function'smtpmail-send-itsmtpmail-smtp-server"smtp.office365.com"smtpmail-smtp-service587;;smtpmail-starttls-credentials '(("smtp.office365.com" 587 nil nil))smtpmail-starttls-credentials"~/.authinfo.gpg"smtpmail-stream-type'starttls);; 根据 from 邮件头使用正确的账户上下文发送 Email.(setqmessage-sendmail-envelope-from'header);; 该函数基于当前所在的 maildir 来判定所账户上下文。(defunmu4e-message-maildir-matches(msgrx)(whenrx(if(listprx);; If rx is a list, try each one for a match(or(mu4e-message-maildir-matchesmsg(carrx))(mu4e-message-maildir-matchesmsg(cdrrx)));; Not a list, check rx(string-matchrx(mu4e-message-fieldmsg:maildir)))));;(setqmu4e-contexts`(,(make-mu4e-context:name"yanghotmail":enter-func(lambda()(mu4e-message"Switch to the yanghotmail context")):match-func(lambda(msg)(whenmsg(mu4e-message-maildir-matchesmsg"^/yanghotmail"))):leave-func(lambda()(mu4e-clear-caches)):vars'((user-mail-address."tiedang.yang@hotmail.com")(user-full-name."Tiedang Yang")(smtpmail-default-smtp-server."smtp.office365.com")(smtpmail-smtp-server."smtp.office365.com")(smtpmail-smtp-service.587)(smtpmail-stream-type.starttls)(mu4e-compose-signature.(concat"Tiedang Yang\n""https://www.junahan.com\n")))),(make-mu4e-context:name"fyangfoxmail":enter-func(lambda()(mu4e-message"Switch to the cesgroup context")):match-func(lambda(msg)(whenmsg(mu4e-message-maildir-matchesmsg"^/yangfoxmail"))):leave-func(lambda()(mu4e-clear-caches)):vars'((user-mail-address."tiedang.yang@foxmail.com")(user-full-name."Yang Tiedang")(smtpmail-default-smtp-server."smtp.qq.com")(smtpmail-smtp-server."smtp.qq.com");;(smtpmail-auth-credentials . '(("smtp.qq.com" 587 "tiedang.yang@foxmail.com" nil)))(smtpmail-smtp-service.587)(smtpmail-stream-type.ssl)(mu4e-compose-signature.(concat"Junahan Yang\n""https://www.junahan.com\n"))))))