Handling Email

Mu4e updates <2016-01-01 Fri>

Added the following so emails are set to format=flowed

;; tip submitted by mu4e user cpbotha
(add-hook 'mu4e-compose-mode-hook
          (defun cpb-compose-setup ()
            "Outgoing mails get format=flowed."
            (use-hard-newlines t 'guess)))

Changed the html2text conversion to

(require 'mu4e-contrib)
(setq mu4e-html2text-command 'mu4e-shr2text)
;; make shr/eww readable with dark themes
;;(setq shr-color-visible-luminance-min 70)
(add-hook 'mu4e-view-mode-hook
            ;; try to emulate some of the eww key-bindings
            (local-set-key (kbd "<tab>") 'shr-next-link)
            (local-set-key (kbd "<backtab>") 'shr-previous-link)))

Installing and configuring mu and mu4e

I am currently testing the combination of Emacs/Spacemacs, mbsync, and mu4e for managing my email. It wasn't exactly straightforward getting it set up but once it was it made managing email within Emacs quite nice. I tried Gnus and it frightened me so this is ok for now. This page contains a running set of notes about the process.

Some links I ran into along the way.

http://www.djcbsoftware.nl/code/mu/mu4e/Installation.html#Installation http://pragmaticemacs.com/emacs/master-your-inbox-with-mu4e-and-org-mode/ http://www.djcbsoftware.nl/code/mu/mu4e/Gmail-configuration.html#Gmail-configuration https://gist.github.com/areina/3879626 https://wiki.archlinux.org/index.php/Isync http://zmalltalker.com/linux/mu.html

`brew install mu` shows this…

OS X provides the BSD gettext library and some software gets confused if both are in the library path.

Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables:

LDFLAGS: -L/usr/local/opt/gettext/lib CPPFLAGS: -I/usr/local/opt/gettext/include

That didn't seem to install mu4e so I uninstalled and did this…

`EMACS=$(which emacs) brew install mu –with-emacs –HEAD`

This put the mu4e package here: /usr/local/Cellar/mu/HEAD/share/emacs/site-lisp so I added that to the config

Installed mbsync via `brew install isync`

Create slave
#Expunge Both
SyncState *

# Gmail ---------------------------------------------------------------
IMAPAccount gmail
# Address to connect to
Host imap.gmail.com
User jack@fusionary.com
Pass [secret]
AuthMechs LOGIN
CertificateFile /usr/local/etc/openssl/cert.pem

IMAPStore gmail-remote
Account gmail

MaildirStore gmail-local
Path ~/Mail/Fusionary/
Inbox ~/Mail/Fusionary/INBOX

Channel gmail-INBOX
Master :gmail-remote:INBOX
Slave :gmail-local:INBOX

Channel gmail-SaneLater
Master :gmail-remote:@SaneLater
Slave :gmail-local:@SaneLater

Channel gmail-Archive
Master ":gmail-remote:[Gmail]/Archive"
Slave :gmail-local:Archive

Channel gmail-Sent
Master ":gmail-remote:[Gmail]/Sent Mail"
Slave ":gmail-local:Sent Mail"

Group gmail-inboxes
Channel gmail-INBOX
Channel gmail-SaneLater

Group gmail-ALL
Channel gmail-INBOX
Channel gmail-SaneLater
Channel gmail-Archive
Channel gmail-Sent

I'm using the develop branch of Spacemacs because there's a new "mu4e" layer. Added the following to my .spacemacs file…

(require 'org-mu4e)
;;store link to message if in header view, not to header query
(setq org-mu4e-link-query-in-headers-mode nil)
(setq mu4e-view-prefer-html nil)
(setq mu4e-attachment-dir "~/Desktop")
(setq mu4e-use-fancy-chars nil) ;; I don't like how it looks so turned it off
(setq mu4e-view-show-addresses t) ;; I prefer to see both name and address
;;(setq mu4e-html2text-command "html2text -utf8 -width 72")
(setq mu4e-html2text-command
      "textutil -stdin -format html -convert txt -stdout")
(add-to-list 'mu4e-view-actions '("ViewInBrowser" . mu4e-action-view-in-browser) t)

(setq mu4e-account-alist
         ;; Under each account, set the account-specific variables you want.
         (mu4e-sent-messages-behavior delete)
         (mu4e-maildir       "~/Mail/Fusionary")
         (mu4e-sent-folder "/Sent Mail")
         (mu4e-drafts-folder "/Drafts")
         (mu4e-refile-folder "/Archive")
         (user-mail-address "jack@fusionary.com")
         (user-full-name "Jack Baty"))
         (mu4e-sent-messages-behavior sent)
         (mu4e-maildir       "~/Mail/Personal")
         (mu4e-sent-folder "/Sent Items")
         (mu4e-drafts-folder "/Drafts")
         (mu4e-refile-folder "/Archive")
         (user-mail-address "jack@baty.net")
         (user-full-name "Jack Baty"))))

(setq mu4e-get-mail-command "mbsync gmail-inboxes")

(setq mu4e-maildir-shortcuts
      '(("/INBOX"             . ?i)
        ("/@SaneLater" . ?l)
        ("/Archive" . ?a)
        ("/Sent Mail" . ?s)
        ("/[Gmail].Trash"     . ?t)))

(setq message-send-mail-function 'smtpmail-send-it
     smtpmail-stream-type 'starttls
     smtpmail-default-smtp-server "smtp.gmail.com"
     smtpmail-smtp-server "smtp.gmail.com"
     smtpmail-smtp-service 587)


Mbsync duplicate UID issue

Update The following setting was the key when using mu4e with mbsync

(setq mu4e-change-filenames-when-moving t)

I was getting an error when syncing the Archive folder `Maildir error: duplicate UID` Found this article which helped fix it. Short version:

find . -name "*U=2:*" -exec ls -l {} \;

Edit the second result's filename by removing everything after the "U=2" portion

Find all duplicates like this:

ls -lR cur | grep -o 'U=.*:' | sort | uniq -d

Author: Jack Baty jack@baty.net.
Last update : 2016-11-05 Sat 14:55