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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<!-- Copyright 1998 - 2021 Double Precision, Inc. See COPYING for -->
<!-- distribution information. -->
<refentry id="imapd">
<info><author><firstname>Sam</firstname><surname>Varshavchik</surname><contrib>Author</contrib></author><productname>Courier Mail Server</productname></info>
<refmeta>
<refentrytitle>imapd</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo>Double Precision, Inc.</refmiscinfo>
</refmeta>
<refnamediv>
<refname>imapd</refname>
<refpurpose>The <application>Courier</application> IMAP server</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis sepchar=" ">
<command>@libexecdir@/couriertcpd</command>
<arg choice="req" rep="norepeat">couriertcpd options</arg>
<arg choice="req" rep="norepeat">@prefix@/sbin/imaplogin</arg>
<arg choice="opt" rep="repeat"><replaceable>modules</replaceable></arg>
<arg choice="req" rep="norepeat">@prefix@/bin/imapd</arg>
<arg choice="req" rep="norepeat">./Maildir</arg>
</cmdsynopsis>
<cmdsynopsis sepchar=" ">
<command>@prefix@/bin/imapd</command>
<arg choice="req" rep="norepeat">./Maildir</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id="imapd_description">
<title>DESCRIPTION</title>
<para>
<command>imapd</command> is the <application>Courier</application>
IMAP server that provides IMAP access to
Maildir mailboxes.
Normally you don't have to worry about it, as <command>imapd</command>
runs automatically after receiving a network connection, accompanied by
the appropriate userid and password.</para>
<para>
<command>couriertcpd</command> opens network ports that receive incoming
IMAP connections.
After an incoming network connections is established,
<command>couriertcpd</command>
runs the command specified by its first argument, which is
<command>imaplogin</command> passing the remaining arguments to
<command>imaplogin</command>.
<command>imaplogin</command> reads the IMAP login userid and password,
then runs the modules specified by its remaining options, which
are <application>Courier</application>
server authentication modules described in the
<ulink url="authlib.html"><citerefentry><refentrytitle>authlib</refentrytitle><manvolnum>7</manvolnum></citerefentry></ulink>
manual page.</para>
<para>
The last daisy-chained command is
<command>imapd</command>, which is the actual IMAP server,
which is started from the logged-in account's home directory.
The sole argument to <command>imapd</command> is the pathname
to the default IMAP mailbox, which is usually
<filename>./Maildir</filename>.
Some authentication modules are capable of specifying a different
filename, by setting the <envar>MAILDIR</envar> environment variable.
</para>
<para>
<command>imapd</command> may also be invoked from the shell prompt, in which
case it issues a <literal>PREAUTH</literal> response, then changes the
current directory to either its
argument, or the contents of the <envar>MAILDIR</envar> environment
variable, then attempts to talk IMAP on standard input and output.</para>
<para>
<command>imapd</command> implements IMAP4REV1, as defined by
<ulink url="http://www.rfc-editor.org/rfc/rfc2060.txt">RFC 2060</ulink>.</para>
</refsect1>
<refsect1 id="imapd_files_and_environment_variables">
<title>FILES AND ENVIRONMENT VARIABLES</title>
<variablelist>
<varlistentry>
<term><envar>AUTH*</envar></term>
<listitem>
<simpara>
<command>imapd</command> examines several environment variables whose
names start with AUTH - these environment variables are set by
<command>imaplogin</command> and the authentication modules.
Their absence tells
<command>imapd</command> that it's running from the command line.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>MAILDIR</envar></term>
<listitem>
<simpara>
<envar>MAILDIR</envar> - if defined,
<command>imapd</command> changes its directory to the
one specified by this environment variable.
Otherwise <command>imapd</command> changes
its directory to the one specified on the command line.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>`<command>pwd</command>`/.</filename></term>
<listitem>
<simpara>
The current directory is assumed to be the main INBOX
Maildir.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>`<command>pwd</command>`/.<replaceable>folder</replaceable></filename></term>
<listitem>
<simpara>
Maildir folders, each one containing their own
tmp, new, cur, etc...</simpara>
</listitem>
</varlistentry>
</variablelist>
<para>
Other environment variables are initialized from the
<filename>@sysconfdir@/imapd</filename> and
<filename>@sysconfdir@/imapd-ssl</filename> configuration files.
These files are loaded into the environment by the system startup script
that runs <command>couriertcpd</command>.</para>
<refsect2 id="imapd_realtime_concurrent_folder_status_updates">
<title>Realtime concurrent folder status updates</title>
<para>
The <application>Courier</application> IMAP server always allows
more than one mail client to have the
same folder opened.
However, when two or more clients have the same folder opened, the mail
clients may not necessarily know when another client added or removed
messages from the folder.
The base IMAP protocol specification requires IMAP mail clients to explicitly
check for any changes to the folder's contents.
No provisions exists to notify the mail client immediately when the folder's
contents are modified by another mail client.</para>
<para>
The <literal>IDLE</literal> extension to the base IMAP protocol provides
a delivery mechanism for notifying mail clients of changes to the mail
folder's contents.</para>
<variablelist>
<varlistentry>
<term><literal>IDLE</literal> IMAP capability</term>
<listitem>
<para>
<literal>IDLE</literal>
must be listed in the
<envar>IMAP_CAPABILITY</envar>
setting in the <filename>@sysconfdir@/imapd</filename>
configuration file.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>IMAP_USELOCKS</envar></term>
<listitem>
<para>
This setting in <filename>@sysconfdir@/imapd</filename>
must be enabled.
This setting uses dot-lock files to synchronize updates to folder indexes
between multiple IMAP clients that have the same folder opened.</para>
<para>
This setting is safe to use with NFS, as it does not use actual file locking
calls, and does not require the services of the problematic NFS lock
daemon.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>An IMAP mail client that fully supports the
<literal>IDLE</literal>
protocol extension.</term>
<listitem>
<para>
Of course, an IMAP client that supports the <literal>IDLE</literal>
protocol extension is required.
At press time the status and extent of <literal>IDLE</literal> support
in most IMAP mail clients is not known.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<para>
Without <envar>IMAP_USERLOCKS</envar> there exists a small possibility
that multiple mail clients will receive a slightly inconsistent folder index
if both clients try to update the contents of the folder at the same time.
Usually, the worst case result is that some clients will eventually end up
downloading the same message twice from the server, and caching it incorrectly
in the local cache (if the IMAP client caches message contents).
Clearing the local message cache will quickly eliminate any residual
confusion that results from this situation.</para>
<para>
Without inotify kernel interface, the
<application>Courier</application> IMAP server will
manually check for changes to the folder's contents every 60 seconds,
in IDLE mode (instead of in real time).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2 id="imapd_verifying_realtime_concurrent_folder_status_updates">
<title>Verifying realtime concurrent folder status updates</title>
<para>
Use the following procedure to verify that realtime concurrent folder status
updates are properly working.
It is helpful to be familiar with the IMAP protocol.
If that's not the case, just be extra careful in entering the IMAP protocol
commands.
The following instructions describe the procedure for connecting to the
IMAP server, and manually issuing IMAP protocol commands, as if they
originate from an IMAP client.
The following instructions use "<literal>C:</literal>" to indicate IMAP
client commands that must be entered, and "<literal>S:</literal>" to
indicate the expected replies from the server.</para>
<note>
<para>
The actual replies from the server may differ slightly, due to the actual
server configuration, and other minor factors.
The following examples have long lines wrapped for readability.
Slight observed differences from the expected replies are normal, but they
should still be substantively the same.</para>
</note>
<orderedlist inheritnum="ignore" continuation="restarts">
<listitem>
<para>
Prepare a test account with a couple of messages.
Open two or three terminal windows.
In each window, connect to the IMAP server, and enter IDLE mode:
</para>
<programlisting format="linespecific">
S:* OK Courier-IMAP ready. Copyright 1998-2021 Double Precision, Inc.
See COPYING for distribution information.
C:a login <replaceable>userid</replaceable> <replaceable>password</replaceable>
S:a OK LOGIN Ok.
C:a SELECT INBOX
S:* FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
* OK [PERMANENTFLAGS (\Draft \Answered \Flagged \Deleted \Seen)]
Limited
* 2 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 939609418] Ok
a OK [READ-WRITE] Ok
C:a IDLE
S:+ entering ENHANCED idle mode
</programlisting>
<note>
<para>
The default <application>Courier</application> IMAP server
configuration permits a maximum of four
connections from the same IP address.
It may be necessary to adjust this setting in
<filename>@sysconfdir@/imapd</filename>
for the duration of this test.</para>
</note>
</listitem>
<listitem>
<para>
The last message from the server must be "entering ENHANCED idle mode".
Otherwise, it means that some of the necessary prerequisites have not been
met.</para>
</listitem>
<listitem>
<para>
Open another terminal window, connect to the server, and modify the flags
of one of the messages:</para>
<programlisting format="linespecific">
S:* OK Courier-IMAP ready. Copyright 1998-2021 Double Precision, Inc.
See COPYING for distribution information.
C:a login <replaceable>userid</replaceable> <replaceable>password</replaceable>
S:a OK LOGIN Ok.
C:a SELECT INBOX
S:* FLAGS (\Draft \Answered \Flagged \Deleted \Seen \Recent)
* OK [PERMANENTFLAGS (\Draft \Answered \Flagged \Deleted \Seen)]
Limited
* 2 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 939609418] Ok
a OK [READ-WRITE] Ok
C:STORE 1 +FLAGS (\Deleted)
* 1 FETCH (FLAGS (\Deleted))
a OK STORE completed.
</programlisting>
</listitem>
<listitem>
<para>
The last command sets the <literal>\Deleted</literal> flag on the first
message in the folder.
Immediately after entering the last command,
"<literal>* 1 FETCH (FLAGS (\Deleted))</literal>" should also appear
in all other terminal windows.
</para>
</listitem>
<listitem>
<para>
Verify that all terminal windows reliably receive folder status updates in
real time by alternatively entering the commands
"<literal>a STORE 1 -FLAGS (\Deleted)</literal>"
and
"<literal>a STORE 1 +FLAGS (\Deleted)</literal>",
to toggle the deleted flag on the first message.
Observe that the message is received by all terminal windows quickly,
and reliably.</para>
</listitem>
<listitem>
<para>
With the <literal>\Deleted</literal> flag set on the first message,
enter the <command>EXPUNGE</command> command, which removes the deleted
message from the folder:</para>
<programlisting format="linespecific">
C:a EXPUNGE
S:* 1 EXPUNGE
* 2 EXISTS
* 0 RECENT
S:a OK EXPUNGE completed
</programlisting>
<para>
The lines that begin with the "*" character should also appear in all other
terminal windows (depending on the initial folder state one of the terminal
windows may have a different <literal>RECENT</literal> message, which is
fine).
</para>
</listitem>
<listitem>
<para>
Use a mail client to create and send a test message to the test account.
As soon as the mail server delivers the message, the following
messages should appear in every terminal window:
</para>
<programlisting format="linespecific">
* 3 EXISTS
* 0 RECENT
* 3 FETCH (FLAGS ())
</programlisting>
<para>
The numbers in these messages may be different, depending upon the
initial contents of the test mail folder.
One of the terminal windows should have a different <literal>RECENT</literal>
count,
and one of the terminal windows should include a
<literal>\Recent</literal> flag in the untagged
<literal>FLAGS</literal> message.
These difference are acceptable; the important thing is to make sure that
all terminal windows have the same <literal>EXISTS</literal> message.
</para>
</listitem>
</orderedlist>
</refsect2>
</refsect1>
<refsect1 id="imapd_see_also">
<title>SEE ALSO</title>
<para>
<ulink url="authlib.html"><citerefentry><refentrytitle>authlib</refentrytitle><manvolnum>7</manvolnum></citerefentry></ulink>,
<ulink url="userdb.html"><citerefentry><refentrytitle>userdb</refentrytitle><manvolnum>8</manvolnum></citerefentry></ulink></para>
</refsect1>
</refentry>
|