aboutsummaryrefslogtreecommitdiffstats
path: root/doc/baseline.mdwn
blob: 29b121b5a421c804f371eb43d0606ce14cf0958f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
---
title: |
 Case of setting up InterIMAP with Dovecot and Mutt on Debian
...

This case guide explains the setup of InterIMAP. The guide also covers
the overview of configuration philosophy and strategy. Eventually how
to configure the Mutt client is covered.

# Overview

A local IMAP server has a local mail store. InterIMAP always
synchronises between two IMAP servers, *local* and *remote*. In this
case the goal is to sync a remote IMAP server with a local one.

The following software components are involved:

 * [Dovecot](https://dovecot.org)
 * [Mutt](http://mutt.org)
 * [InterIMAP](https://git.guilhem.org/interimap/about/)

The environment is assumed to be Debian Stable, Debian 9 Stretch. For
InterIMAP, however the Debian testing repository needs to be available
for the purpose of installation.

The mail client (Mutt) is served via IMAP from a local instance of
Dovecot. Local storage will be Maildir format. Using the IMAP server
to serve content to the mail client is preferred, compared to using the
client's internal Maildir support.

The setup corresponds to multiple running instances of Dovecot
processes: Dovecot is invoked with a separate instance for every
client session, as well as for the instance of InterIMAP. This is of
course no problem. All process connect the same mail storage,
including caching data, etc.

On configuration, the setup is straight forward. Also, all
configuration and services are user local. no system wide
configuration changes will be needed. The system wide dovecot service
is even disabled.

# Install software

Make sure testing is in sources. Install (run as root):

    apt-get install interimap dovecot-imapd

<!--
# Structure of Maildir locally

*TODO Explain the local storage setup*

-->

What is the "fripost" abstraction?

 - private
 - work

The use of "private" is for contrasting that to possible completing
"work" accounts, or similar.  Replace "private" in all of continuation
with what describes your account. E.g. authors would use "fripost".

```
ACCOUNT=private
```

Note on delimiters. Below is referred to "separator". That has to do
with the server-client IMAP communication and should not be confused
with the Maildir mail folder delimiter. Maildir hierarchy delimiter
will always be "." (period).

# Setup Dovecot

Disable the system wide Dovecot service (run as sudo):

```
systemctl stop dovecot
systemctl disable dovecot
```

Provide local configuration for Dovecot:

```
mkdir -pm 0700 "${XDG_CONFIG_HOME:-$HOME/.config}/dovecot"
tee "${XDG_CONFIG_HOME:-$HOME/.config}/dovecot/$ACCOUNT.conf" <<-EOF
namespace inbox {
    location  = maildir:~/Maildir/$ACCOUNT
    inbox     = yes
    list      = yes
    separator = /
}
EOF
```

Verify connectivity and setup with the following:

    doveadm -c "${XDG_CONFIG_HOME:-$HOME/.config}/dovecot/$ACCOUNT.conf" exec imap

you should see long output pattern `* PREAUTH ... Logged in as
...`. The PREAUTH shows your authenticated at login. Type the command
`a list "" "*"` to list your mailboxes. Logout with `b logout`.

Create a wrapper for execution

```
install -m 0755 /dev/stdin ~/.local/bin/imap <<EOF
#!/bin/sh
exec doveadm -c "\${XDG_CONFIG_HOME:-\$HOME/.config}/dovecot/\$1.conf" exec imap
EOF
```

# Configure email client (Mutt)

Put in your mutt configuration:

```
set tunnel = "exec ~/.local/bin/imap private" # Put here what describes your account
set folder = "imap://foo"
set spoolfile = "imap://foo"
```

# Configure InterIMAP

Prepare config.

```
mkdir -m 0700 -p "${XDG_CONFIG_HOME:-$HOME/.config}/interimap"
install -m 0600 /usr/share/doc/interimap/interimap.sample "${XDG_CONFIG_HOME:-$HOME/.config}/interimap/$ACCOUNT"
```

Edit your InterIMAP configuration
(e.g. *~/.config/interimap/private*):

 * Remove *list-select-opts* option
 * Edit *local* and *remote* sections

```
[local]
type = tunnel
command = exec ~/.local/bin/imap private
null-stderr = YES

[remote]
#type = imaps
host = imap.example.net
#port = 993
#proxy = socks5h://localhost:9050
username = user
password = xxxxxxxxxxxxxxxx
#compress = YES
```

In accordance with the case above of the authors "imap.example.net"
should be "imap.fripost.org", "user" e.g. "gustav.eek@fripost.org",
"xxxxxx..." your password.

# Systemd setup

Here's a documentation bifurcation depending on Debian version: Debian
10 Buster vs. Debian 11 Bullseye and later.

## Bullseye

The easier case is for *Bullseye*.

Enable the service for your user.

```
systemctl --user start interimap@$ACCOUNT.service
systemctl --user enable interimap@$ACCOUNT.service
```

In need of configuration change override the system wide configuration
(in */usr/lib/systemd/user/interimap.service*), e.g:


```
mkdir -m 0755 -p "${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/interimap@.service.d"
install -m 0644 /dev/stdin "${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/interimap@.service.d/override.conf" <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/interimap --config=%i --watch=20
EOF
systemctl --user daemon-reload
```

This is standard Systemd configuration. See "systemd.unit(5)".

## Buster

For older Debian version, such as *Buster* or *Stretch* setup is more
tedious.


The easier case is for *Bullseye*.

Enable the service for your user.

```
systemctl --user start interimap@$ACCOUNT.service
systemctl --user enable interimap@$ACCOUNT.service
```

In need of configuration change override the system wide configuration
(in */usr/lib/systemd/user/interimap.service*), e.g:


```
mkdir -m 0755 -p "${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/interimap@.service.d"
install -m 0644 /dev/stdin "${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/interimap@.service.d/override.conf" <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/interimap --config=%i --watch=20
EOF
systemctl --user daemon-reload
```

This is standard Systemd configuration. See "systemd.unit(5)".