all repos — site @ 7b5aac0bbeeb8fbd236d8487a2c881b52fa36406

source for my site, found at icyphox.sh

pages/txt/s-nail.txt (view raw)

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