123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <!DOCTYPE html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><meta name="keywords" content="GNU, Emacs, Libre Software, Hurd, Guile, Guix" /><meta name="description" content="GNUcode.me is a website focusing on libre software projects, especially the GNU project." /><link type="application/atom+xml" rel="alternate" title="GNUcode.me -- Feed" href="/feed.xml" /><a rel="me" href="https://fosstodon.org/@thegnuguy"></a><link type="text/css" href="css/footer.min.css" rel="stylesheet"></link><link type="text/css" href="css/header.min.css" rel="stylesheet"></link><link type="text/css" href="css/main.min.css" rel="stylesheet"></link><title>A Locally Running Dovecot in Guix — GNUcode.me</title></head><body><header><nav><ul><li><a href="index.html">GNUcode.me</a></li><li><a href="services.html">Services</a></li><li><a href="about.html">About</a></li><li><a href="business-ideas.html">Business-ideas</a></li></ul></nav></header><h1>A Locally Running Dovecot in Guix</h1><main><section class="basic-section-padding"><article><h3>by Joshua Branson — June 08, 2021</h3><div><p>So, I have been wanting to set up a locally running dovecot server for a LONG
- time now. Essentially I have an email account at <a href="dismail.de">dismail.de</a>, and
- Emacs' <a href="https://www.gnu.org/software/emacs/manual/html_node/gnus/">Gnus</a> is
- pretty slow at searching for my emails. I could switch to using mu4e or
- notmuch, which ARE BLAZINGLY fast at searching your emails, BUT after listening
- to John Wiegley, who is one of the current
- <a href="https://www.gnu.org/software/emacs/">Emacs</a> maintainers, talk about how Emacs'
- Gnus mode is so cool...I've been using Gnus ever since. Essentially Gnus is a
- newsreader. It is a way to handle lots news that is similar to reddit. In
- Gnus, after you've read a message, you do not see it again by default. This is
- handy, because since you are getting so much email, it's useful to only see
- messages that you have not read.</p><p>Emacs's Gnus is actually the best way I've seen at handling LOTS of email,
- particularly mailing lists. For example, I am currently subscribed to
- <a href="https://lists.gnu.org/mailman/listinfo/guix-devel">guix-devel</a>,
- <a href="https://lists.gnu.org/mailman/listinfo/help-guix">help-guix</a>, and
- <a href="https://lists.gnu.org/mailman/listinfo/bug-hurd">bug-hurd</a>. With Gnus, I can
- open up these email folders and I only see messages that I have not read, AND
- the emails are organized by threads NOT date:</p><p><img src="./images/gnus-thread.png" alt="Image" /></p><p>With my cursor on the top of the thread, pressing C-k, will kill the entire
- thread. So when I open up this folder again, I will not see that thread. Let's
- suppose that I've read all of the messages in that thread "Re: website: A little
- help running the website locally". So that now Gnus looks like this when I open
- it up:</p><p><img src="./images/gnus-thread-all-but-one.png" alt="Image" /></p><p>Pressing Shift-A-Shift-T, will pull up the entire thread, so that I can re-read
- the whole conversation:</p><p><img src="./images/gnus-thread-all-but-one-reopened.png" alt="Image" /></p><p>Anyway, the main problem that I have had with Gnus (for years...I should have
- fixed this a long time ago), is that it is REALLY slow and pretty much not
- responsive at searching for my email. I could try to search for my email with
- Gnus, but it would typically fail. I guess that something with dismail's
- servers are wonky, because I did not have this problem when I had a paid
- <a href="fastmail.com">fastmail</a> account.</p><p>So, one solution to continue using Gnus, but have decent searching is to have a
- locally running <a href="https://www.dovecot.org/">dovecot</a> server that will serve my
- emails. I'll also be querying that local server instead of the remote one.
- Sounds plausible. Here's what you need to do:</p><p>First you need to fetch your remote email and put it in a local
- <a href="https://en.wikipedia.org/wiki/Maildir">maildir</a>. I prefer
- <a href="https://isync.sourceforge.io/mbsync.html">mbsync</a>, because it is what all the
- cool kids are doing.</p><p>Here is my <code>~/.mbsyncrc</code></p><pre><code>IMAPAccount dismail
- # Address to connect to
- Host imap.dismail.de
- User jbranso@dismail.de
- Pass VERYSECRETPASSWORD
- # To store the password in an encrypted file use PassCmd instead of Pass
- # PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.mailpass.gpg"
- #
- # Use SSL
- SSLType IMAPS
- CertificateFile /etc/ssl/certs/ca-certificates.crt
- IMAPStore dismail-remote
- Account dismail
- MaildirStore dismail-local
- Subfolders Verbatim
- # The trailing "/" is important
- Path ~/.mail/dismail.de/
- Inbox ~/.mail/dismail.de/Inbox
- Channel dismail
- Master :dismail-remote:
- Slave :dismail-local:
- # show all folders
- Patterns *
- # Automatically create missing mailboxes, both locally and on the server
- Create Both
- # Save the synchronization state files in the relevant directory
- SyncState *</code></pre><p><code>mbsync -a</code> running in a cron job, syncs up my email. The config in guix for
- that looks like so:</p><pre><code class="language-scheme">(define mbsync-every-5-minutes
- ;; The job's action is a shell command.
- #~(job "*/5 * * * *" ;Vixie cron syntax
- "mbsync -Va"
- #:user "joshua"))
- ...
- (operating-system
- ...
- (services
- (append
- (list
- (service mcron-service-type
- (mcron-configuration
- (jobs (list mbsync-every-5-minutes)))))
- %desktop-services)))</code></pre><p>Now all we need is the configuration for a locally running dovecot server, which
- looks like so:</p><pre><code class="language-scheme">(dovecot-service #:config
- (dovecot-configuration
- (mail-location "maildir:~/.mail/dismail.de:LAYOUT=fs")
- (listen '("127.0.0.1"))
- ;; I do not need ssl support in a locally running dovecot. :)
- (ssl? "no")
- (protocols
- (list (protocol-configuration
- (name "imap")
- (mail-max-userip-connections 1))))
- (services (list
- (service-configuration
- (kind "imap")
- (client-limit 1)))))</code></pre><p>The bit that really got me confused for a while was that I needed <strong>LAYOUT=fs</strong>
- in the mail-location line. Essentially, isync creates a maildir in a slightly
- different format than what dovecot expects. Adding in the "LAYOUT=fs" fixes this.</p><p>The last bit is we have to tell Emacs how to connect to the server:</p><pre><code class="language-scheme">(setq
- user-mail-address "myemailaccount@dismail.de"
- user-full-name "Joshua Branson")
- (setq gnus-secondary-select-methods
- '((nnimap "localDismail"
- (nnimap-address "localhost")
- (nnimap-stream network)
- (nnimap-server-port 143)
- )))</code></pre><p>Pretty cool stuff? Right!?</p></div></article></section></main><footer><p>© 2020 Joshua Branson. The text on this site is free culture under the Creative Commons Attribution Share-Alike 4.0 International license.</p><p>This website is build with Haunt, a static site generator written in Guile Scheme. Source code is <a href="https://notabug.org/jbranso/gnucode.me">available.</a></p><p>The color theme of this website is based off of the famous <a href="#3f3f3f" target="_blank">zenburn</a> theme.</p></footer></body>
|