Guide to email in Emacs using mu and mu4e
cachestocaches.com
cachestocaches.com
This is the worst thing about mu/mu4e. You need to do the indexing with a timer in Emacs, and because Emacs is single-threaded this blocks things / slows down the UI. After trying to get it to work in some automated way I gave up. I manually issue a key-combo to re-index and then read my E-Mail.
Another comment: I recommend not using Emacs to send E-Mail, but to outsource this to a local smtpd such as Exim (which I use with mu4e on Debian). Then if you don't have WiFi or whatever the smtpd just queues those up for later sending, and has queue inspection tools etc. All of the solutions for doing this in Emacs itself are dirty hacks full of edge cases and bugs smtpds have solved decades ago.
Despite some rough edges, mu+mu4 (plus Exim, or similar). is an amazing tool, and the most useful E-Mail client I've ever used.
$ mu index [...]
mu: mu_store_new_writable: xapian
error 'Unable to get write lock on
<Maildir>/xapian: already locked' (11)
How do you send E-Mail with no network connection? Last I checked this was some ad-hoc thing where you neede dto queue them up in some queue managed by Emacs, and remember to turn that mode off when you were back on WiFi (or hack up your own hooks to automate this), v.s. sending it to a local smtpd which already has retry logic built-in.I never have a scenario where I need to send email without network.
It's worth noting that multithreading recently landed in Emacs master, so it's now possible to avoid this sort of problem.
http://notes.secretsauce.net/notes/2014/12/12_mu4e-and-desktop-notifications.html
I.e. there's an external script that invokes IMAP IDLE. And when IMAP tells it there's new mail, the script tells EMACS there's new mail. Then the reindexing happens within the emacs, and it uses the lock it already has. Makes this particular issue go away completely.¯\_(ツ)_/¯
> This is the worst thing about mu/mu4e. You need to do the indexing with a timer in Emacs, and because Emacs is single-threaded this blocks things / slows down the UI. After trying to get it to work in some automated way I gave up. I manually issue a key-combo to re-index and then read my E-Mail.
I tried both approaches (actually, I had mu4e reindex on `g` query refresh, no need for separate keybindings), and prefer having indexing run after IMAP sync. I don't notice any problems (and I mostly use very slow Atom hardware).
> Another comment: I recommend not using Emacs to send E-Mail, but to outsource this to a local smtpd such as Exim (which I use with mu4e on Debian). Then if you don't have WiFi or whatever the smtpd just queues those up for later sending, and has queue inspection tools etc. All of the solutions for doing this in Emacs itself are dirty hacks full of edge cases and bugs smtpds have solved decades ago.
FUD. smtpmail.el can do this. smtpmail.el can queue mail, and you can run it in a separate Emacs process periodically or on demand, to attempt to deliver those emails. The emails are queued as files in a directory, so you don't need separate queue inspection tools. I run smtpmail.el this way with mu4e, and think it is a far superior solution to having to install and configure yet another external program.
I also recommend isync's mbsync over offlineimap
I primarily use mu4e but want to see changes on my mobile as well as on any remote computer using a web client in a browser.
As far as I know notmuch can just be synchronized to another notmuch instance.
Personally, I don't bother with it. When I have to do mail on my phone, it's usually so limited in scope that I don't need to retain state when I sit down at my main computer. I can imagine that's not for everyone, though.
$ pgrep mu && kill `pgrep mu`
$ mu index
It works perfectly. Mu4e then restarts mu when it needs it.
I think I saw that as the recommended setup somewhere in the mu docs.
This could be rewritten as:
$ pkill mu
`pkill -x mu` matches the whole name without substrings.
But on the other hand. great job and THANKS.
Do you have any hint?
I've looked at a lot of solutions, and AFAICT:
- SMTP + app-based passwords require "insecure access" being enabled
-Using the GMail HTTP API does not require insecure access, but none of the standard CLI email tools support it.
From https://myaccount.google.com/lesssecureapps
"This setting is not available for accounts with 2-step verification enabled. Such accounts require an app-specific password to access less secure apps"
offlineimap supports it, and the config file has setup instructions: https://github.com/OfflineIMAP/offlineimap/blob/master/offli...
In my opinion, Notmuch is better than Mu because it has a really neat architecture that allows customizing it to embrace any possible email workflow with a few trivial Bash commands.
Notmuch is purely tag based. It will never ever modify your mailbox. It's your task to map tags to imperative mailbox actions (delete, move...) using some shell hooks. Most workflows can be trivially implemented by calling the notmuch backend and piping the output to mv or rm using xargs or parallel.
Since searching in Notmuch is really quick, I recommend never manually assigning tags and tagging everything with rules written in the backend for those repetitive searches that you want a shortcut for. This is not specific to Notmuch, but also applies to Mu.
Mu has a hybrid tag/folder model, and the interface resembles Mutt in some ways. The other key difference with Notmuch is that Mu stores tags using a special header in each message. Notmuch uses a separate database, which is not synced across computers (unless you rsync it explicitly). I prefer the latter approach, as modifying your mailbox to store tags is a bit ugly and slow. I also favor not tagging things manually, but using rules. Then syncing tags becomes unnecessary.
The reason I ask: When I look around, I tend to see a lot more references to mu4e than to notmuch. Is it just easier to start with, or does it actually have some nicer features that notmuch doesn't?
Not sure if it's relevant, but: I download all emails and do not want to sync with the server.
With mu, you just do the normal thing: instead of tagging a message as "x", you put it in folder "x". Clearly this breaks down if you want to apply more than one tag to a message, but this hasn't been an issue for me in the 20+ years I've been using email.
Before I read this, I had no idea that mu even did any tag-based anything.
IMAP only supports a few tags: read, unread... But not custom ones.
The only possible scenario where Mu is better than Notmuch is where you have many many custom tags and you want them to be perfectly synced across Emacs instances in different computers. Since Mu stores them in messages, this is very easy. With Notmuch, you'll need to separately sync the database. E.g. by rsyncing it.
But note that other clients won't understand these tags.
I think there is more or less feature parity.
However, out of the Emacs world, Notmuch is very very popular as a Mutt search backend.
I'm currently playing around with mblaze, which is another command line mail-reading toolkit (https://github.com/chneukirchen/mblaze ), and building some notmuch-friendly tools on top of that ( https://github.com/dannyob/mblaze-much ). I'm not sure it's the right way forward, but it's proving to be a fun experiment.
Is there a way to read/write emails on Emacs, without having any emails or credentials stored locally as plaintext? I'm heavily prioritizing ease of configuration and security over speed or other additional features.
I don't do this and just keep my password in plain-text and use full-disk-encryption, because I don't want to have to be constantly unlocking a keyring to have some background E-Mail syncing job work.
Otherwise, password-read or something like that.
https://www.gnu.org/software/emacs/manual/html_node/auth/Gnu...
When I set it up with gmail tough, I think you either need a 2fa token (which requires 2fa on gmail) or tick "allow unsafe apps" in the admin panel, otherwise you get rejected by gmail. I'm sorry I don't have much info, it's already been a few months I've set it up. However, if anyone's struggling, I'll be glad to help ;)
As for the writing of mail, it culminates in running some kind of sendmail program on your message. If you have sendmail or postfix setup locally to forward mail up to another server, you already don't need to have a password set up in Emacs. But you could also make that program do whatever you want, it just needs to be a binary that accepts certain arguments (or an emacs function that operates on the file).
https://github.com/thejefflarson/getpasswd
It accesses the OS keychain to get the right password. I don't use offlineimap -- I use mbsync instead which has a PassCmd option where you can pass in a shell command (e.g. getpasswd <imap-server> <imap-user>). And another tool to add passwords to the GNOME Keychain:
https://github.com/thejefflarson/setpasswd
Adding passwords to the OSX keychain is easy enough, but I found it fiddly in Gnome's GUI. YMMV.
* OfflineIMAP -- to download and synchronize local Maildir with remote IMAP.
* Mutt -- E-mail client (understatement).
* Notmuch -- for fast local indexing and querying.
* Postfix -- the wonderful mail transfer agent.
Here[1] are some config files (from my colleague, Paul Frields) that you can adapt from.
Been using the above set up for about five years. They heavily help with the high-traffic open source projects that use mailing lists for patches. (Even for general mail setup, this is still useful).
These tools are a part of my day-to-day happiness at work.
The downside is that for whatever reason the Gmail API doesn't support the mute label, so having that tag sync is not possible. (If a Googler reads this, please fix that! For others, there's already an issue filed as referenced in the gmailieer readme.)
[1] I'm still spooked from the time my Gmail account was suspended for no apparent reason, having to contact support and being without email for nearly a week.