all repos — site @ master

source for my site, found at icyphox.sh

pages/blog/s-nail.md (view raw)

  1---
  2template:
  3slug: s-nail
  4title: The S-nail mail client
  5subtitle: And how to achieve a usable configuration for IMAP/SMTP
  6date: 2020-05-06
  7---
  8
  9TL;DR: Here's my [`.mailrc`](https://github.com/icyphox/dotfiles/blob/master/home/.mailrc).
 10
 11As I'd mentioned in my blog post about [mael](/blog/mael), I've been on
 12the lookout for a good, usable mail client. As it happens, I found
 13S-nail just as I was about to give up on mael. Turns out writing an MUA
 14isn't all too easy after all. S-nail turned out to be the perfect client
 15for me, but I had to invest quite some time in reading the [very
 16thorough manual](https://www.sdaoden.eu/code-nail.html) and exchanging
 17emails with its [very friendly author](https://www.sdaoden.eu). I did it
 18so you don't have to[^read-man], and I present to you
 19this guide.
 20
 21[^read-man]: Honestly, read the man page (and email Steffen!) -- there's
 22    a ton of useful options in there.
 23
 24## basic settings
 25
 26These settings below should guarantee some sane defaults to get started
 27with. Comments added for context.
 28```conf
 29# enable upward compatibility with S-nail v15.0
 30set v15-compat
 31
 32# charsets we send mail in
 33set sendcharsets=utf-8,iso-8859-1
 34
 35# reply back in sender's charset
 36set reply-in-same-charset
 37
 38# prevent stripping of full names in replies
 39set fullnames
 40
 41# adds a 'Mail-Followup-To' header; useful in mailing lists
 42set followup-to followup-to-honour-ask-yes
 43
 44# asks for an attachment after composing
 45set askattach
 46
 47# marks a replied message as answered
 48set markanswered
 49
 50# honors the 'Reply-To' header
 51set reply-to-honour
 52
 53# automatically launches the editor while composing mail interactively
 54set editalong
 55
 56# I didn't fully understand this :) 
 57set history-gabby=all
 58
 59# command history storage
 60set history-file=~/.s-nailhist
 61
 62# sort mail by date (try 'thread' for threaded view)
 63set autosort=date
 64```
 65
 66## authentication
 67
 68With these out of the way, we can move on to configuring our
 69account -- authenticating IMAP and SMTP. Before that, however, we'll
 70have to create a `~/.netrc` file to store our account credentials. 
 71
 72(This of course, assumes that your SMTP and IMAP credentials are the
 73same. I don't know what to do otherwise. )
 74
 75```netrc
 76machine *.domain.tld login user@domain.tld password hunter2
 77```
 78
 79Once done, encrypt this file using `gpg` / `gpg2`. This is optional, but
 80recommended.
 81
 82```
 83$ gpg2 --symmetric --cipher-algo AES256 -o .netrc.gpg .netrc
 84```
 85
 86You can now delete the plaintext `.netrc` file. Now add these lines to
 87your `.mailrc`:
 88
 89```conf
 90set netrc-lookup
 91set netrc-pipe='gpg2 -qd ~/.netrc.gpg'
 92```
 93
 94Before we define our account block, add these two lines for a nicer IMAP
 95experience:
 96
 97```conf
 98set imap-cache=~/.cache/nail
 99set imap-keepalive=240
100```
101
102Defining an account is dead simple. 
103
104```conf
105account "personal" {
106    localopts yes
107    set from="Your Name <user@domain.tld>"
108    set folder=imaps://imap.domain.tld:993
109
110    # copy sent messages to Sent; '+' indicates subdir of 'folder' 
111    set record=+Sent
112    set inbox=+INBOX
113    
114    # optionally, set this to 'smtps' and change the port accordingly
115    # remove 'smtp-use-starttls'
116    set mta=smtp://smtp.domain.tld:587 smtp-use-starttls
117
118    # couple of shortcuts to useful folders
119    shortcut sent +Sent \
120        inbox +INBOX \
121        drafts +Drafts \
122        trash +Trash \
123        archives +Archives
124}
125
126# enable account on startup
127account personal
128```
129
130You might also want to trash mail, instead of perma-deleting them
131(`delete` does that). To achieve this, we define an alias:
132
133```
134define trash {
135    move "$@" +Trash
136}
137
138commandalias del call trash
139```
140
141Replace `+Trash` with the relative path to your trash folder.
142
143
144## aesthetics
145
146The fun stuff. I don't feel like explaining what these do (hint: I don't
147fully understand it either), so just copy-paste it and mess around with
148the colors:
149
150```
151# use whatever symbol you fancy
152set prompt='> '
153
154colour 256 sum-dotmark ft=bold,fg=13 dot
155colour 256 sum-header fg=007 older
156colour 256 sum-header bg=008 dot
157colour 256 sum-header fg=white
158colour 256 sum-thread bg=008 dot
159colour 256 sum-thread fg=cyan
160```
161
162The prompt can be configured more extensively, but I don't need it. Read
163the man page if you do.
164
165## essential commands
166
167Eh, you can just read the man page, I guess. But here's a quick list off
168the top of my head:
169
170- `headers`: Lists all messages, with the date, subject etc.
171- `mail`: Compose mail.
172- `<number>`: Read mail by specifiying its number on the message list.
173- `delete <number>`: Delete mail.
174- `new <number>`: Mark as new (unread).
175- `file <shortcut or path to folder>`: Change folders. For example: `file
176    sent`
177
178That's all there is to it.
179
180*This is day 2 of the #100DaysToOffload challenge. I didn't think I'd
181participate, until today. So yesterday's post is day 1. Will I keep at
182it? I dunno. We'll see.*