HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/lib/courier-imap/man/man8/imapd.8
.\"  <!-- $Id: imapd.sgml,v 1.2 2002/10/13 20:42:00 mrsam Exp $ -->
.\"  <!-- Copyright 1998 - 2001 Double Precision, Inc.  See COPYING for -->
.\"  <!-- distribution information. -->
.\" This manpage has been automatically generated by docbook2man 
.\" from a DocBook document.  This tool can be found at:
.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
.\" Please send any bug reports, improvements, comments, patches, 
.\" etc. to Steve Cheng <steve@ggi-project.org>.
.TH "IMAPD" "8" "19 February 2004" "Double Precision, Inc." ""

.SH NAME
imapd \- Courier-IMAP server
.SH SYNOPSIS

\fB/usr/lib/courier-imap/libexec/couriertcpd\fR \fBcouriertcpd options\fR \fB/usr/lib/courier-imap/sbin/imaplogin\fR [ \fB\fImodules\fB\fR\fI ...\fR ] \fB/usr/lib/courier-imap/bin/imapd\fR \fB\&./Maildir\fR


\fB/usr/lib/courier-imap/bin/imapd\fR \fB\&./Maildir\fR

.SH "DESCRIPTION"
.PP
\fBimapd\fR is the \fBCourier-IMAP\fR
server that provides IMAP access to
Maildir mailboxes.
Normally you don't have to worry about it, as \fBimapd\fR
runs automatically after receiving a network connection, accompanied by
the appropriate userid and password.
.PP
\fBcouriertcpd\fR opens network ports that receive incoming
IMAP connections.
After an incoming network connections is established,
\fBcouriertcpd\fR
runs the command specified by its first argument, which is
\fBimaplogin\fR passing the remaining arguments to
\fBimaplogin\fR\&.
\fBimaplogin\fR reads the IMAP login userid and password,
then runs the modules specified by its remaining options, which
are Courier authentication modules described in the
\fBauthlib\fR(7)
manual page.
.PP
The last daisy-chained command is
\fBimapd\fR, which is the actual IMAP server,
which is started from the logged-in account's home directory.
The sole argument to \fBimapd\fR is the pathname
to the default IMAP mailbox, which is usually
\fI\&./Maildir\fR\&.
Some authentication modules are capable of specifying a different
filename, by setting the \fBMAILDIR\fR environment variable.
.PP
\fBimapd\fR may also be invoked from the shell prompt, in which
case it issues a PREAUTH response, then changes the
current directory to either its
argument, or the contents of the \fBMAILDIR\fR environment
variable, then attempts to talk IMAP on standard input and output.
.PP
\fBimapd\fR implements IMAP4REV1, as defined by
RFC 2060\&.
.SH "FILES AND ENVIRONMENT VARIABLES"
.TP
\fBAUTH*\fR
\fBimapd\fR examines several environment variables whose
names start with AUTH - these environment variables are set by
\fBimaplogin\fR and the authentication modules.
Their absence tells
\fBimapd\fR that it's running from the command line.
.TP
\fBMAILDIR\fR
\fBMAILDIR\fR - if defined,
\fBimapd\fR changes its directory to the
one specified by this environment variable.
Otherwise \fBimapd\fR changes
its directory to the one specified on the command line.
.TP
\fB\fI`\fBpwd\fI`/.\fB\fR
The current directory is assumed to be the main INBOX
Maildir.
.TP
\fB\fI`\fBpwd\fI`/.folder\fB\fR
Maildir folders, each one containing their own
tmp, new, cur, etc...
.PP
Other environment variables are initialized from the
\fI/usr/lib/courier-imap/etc/imapd\fR and
\fI/usr/lib/courier-imap/etc/imapd-ssl\fR configuration files.
These files are loaded into the environment by the system startup script
that runs \fBcouriertcpd\fR\&.
.SS "REALTIME CONCURRENT FOLDER STATUS UPDATES"
.PP
Setting the IMAP_ENHANCEDIDLE to
1 in
\fI/usr/lib/courier-imap/etc/imapd\fR enables realtime concurrent folder
status updates.
When relatime folder status updates are enabled all IMAP mail clients
that have the same folder open will be
immediately notified of any changes to the folder's contents.
.PP
The Courier-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.
.PP
The IDLE extension to the base IMAP protocol provides
a delivery mechanism for notifying mail clients of changes to the mail
folder's contents.  Although at this time it's not known to which extent
the IDLE extension is supported by IMAP mail clients,
the Courier-IMAP server fully implements the IDLE
extension provided that the following requirements are met:
.TP
\fBFAM\fR
The
File Alteration Monitor package, FAM, must be properly installed and
configured prior to installing Courier-IMAP.

\fBFAM\fR is an application library that
provides an interface to the operating system's kernel
that applications can use to be notified when specific files
or directories are changed, and Courier-IMAP leverages this API to implement
realtime concurrent folder status updates.
According to the most recently available documentation,
\fBFAM\fR
builds and runs on Linux and IRIX.
\fBFAM\fR
should also build on other platform, but without a supported kernel monitor
FAM will fall back to a polling mode.
At press time,
\fBFAM\fR\&'s
web site reports that
\fBFAM\fR
succesfully builds (in polling mode) on FreeBSD and Solaris.

\fBFAM\fR
also works with NFS filesystems.
On NFS clients \fBfam\fR transparently forwards file monitoring
requests to a peer \fBfam\fR process on the NFS server.

Installation and configuration of \fBFAM\fR is beyond
the scope of this document.  This documentation presumes that FAM is
succesfully installed.  Use the resources and tools on
FAM's web site
for assistance with setting up FAM.
Systems that use GNOME or KDE desktops already have
\fBFAM\fR
installed, as
\fBFAM\fR
is used by the current versions of both desktops.
.TP
\fBIDLE IMAP capability\fR
IDLE
must be listed in the
\fBIMAP_CAPABILITY\fR
setting in the \fI/usr/lib/courier-imap/etc/imapd\fR
configuration file.
This is the default setting in new Courier-IMAP 1.6.0/Courier 0.40 installs.
The default setting in previous versions of the server does not include
the IDLE capability.
When upgrading from the previous version the IDLE
capability must be manually added.
.TP
\fBIMAP_USELOCKS\fR
This setting in \fI/usr/lib/courier-imap/etc/imapd\fR
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.

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.
.TP
\fBAn IMAP mail client that fully supports the IDLE protocol extension.\fR
Of course, an IMAP client that supports the IDLE
protocol extension is required.
At press time the status and extent of IDLE support
in most IMAP mail clients is not known.
.TP
\fBIMAP_ENHANCEDIDLE\fR
This setting in \fI/usr/lib/courier-imap/etc/imapd\fR
actually enables concurrent realtime folder status updates using the
IDLE extension.
Note that it is possible to enable the IDLE extension
even if \fBFAM\fR is not available, or without
enabling either the \fBIMAP_USELOCKS\fR and/or
\fBIMAP_ENHANCEDIDLE\fR settings.
The resulting consequences are described are as follows:
.RS
.TP 3
1. 
Without \fBIMAP_USERLOCKS\fR 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.
.TP 3
2. 
Without \fBFAM\fR, and
\fBIMAP_ENHANCEDIDLE\fR set, the Courier-IMAP server will
manually check for changes to the folder's contents every 60 seconds,
in IDLE mode (instead of in real time).
.RE
.SS "VERIFYING REALTIME CONCURRENT FOLDER STATUS UPDATES"
.PP
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 "C:" to indicate IMAP
client commands that must be entered, and "S:" to
indicate the expected replies from the server.
.sp
.RS
.B "Note:"
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.
.RE
.TP 3
1. 
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:

.nf
S:* OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc.
  See COPYING for distribution information.
C:a login \fIuserid\fR \fIpassword\fR
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
.fi
.sp
.RS
.B "Note:"
The default Courier-IMAP server configuration permits a maximum of four
connections from the same IP address.
It may be necessary to adjust this setting in
\fI/usr/lib/courier-imap/etc/imapd\fR
for the duration of this test.
.RE
.TP 3
2. 
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.
Verify that \fBFAM\fR was set up prior to installing
Courier-IMAP (use \fBldd\fR(1)
to verify that the \fBimapd\fR executable is linked with
the \fIlibfam\fR library), and verify the settings in the
\fI/usr/lib/courier-imap/etc/imapd\fR\&.
.TP 3
3. 
Open another terminal window, connect to the server, and modify the flags
of one of the messages:

.nf
S:* OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc.
  See COPYING for distribution information.
C:a login \fIuserid\fR \fIpassword\fR
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.
.fi
.TP 3
4. 
The last command sets the \\Deleted flag on the first
message in the folder.
Immediately after entering the last command,
"* 1 FETCH (FLAGS (\\Deleted))" should also appear
in all other terminal windows.
On systems where \fBFAM\fR uses the fall-back polling
mode this response may appear after a brief delay of a few seconds.
The delay should never exceed 15-20 seconds.
.TP 3
5. 
Verify that all terminal windows reliably receive folder status updates in
real time by alternatively entering the commands
"a STORE 1 -FLAGS (\\Deleted)"
and
"a STORE 1 +FLAGS (\\Deleted)",
to toggle the deleted flag on the first message.
Observe that the message is received by all terminal windows quickly,
and reliably.
.TP 3
6. 
With the \\Deleted flag set on the first message,
enter the \fBEXPUNGE\fR command, which removes the deleted
message from the folder:

.nf
C:a EXPUNGE
S:* 1 EXPUNGE
  * 2 EXISTS
  * 0 RECENT
S:a OK EXPUNGE completed
.fi

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 RECENT message, which is
fine).
.TP 3
7. 
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:

.nf
* 3 EXISTS
* 0 RECENT
* 3 FETCH (FLAGS ())
.fi

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 RECENT
count,
and one of the terminal windows should include a
\\Recent flag in the untagged
FLAGS message.
These difference are acceptable; the important thing is to make sure that
all terminal windows have the same EXISTS message.
.SH "SEE ALSO"
.PP
\fBauthlib\fR(7),
\fBuserdb\fR(8)