IMAP: Difference between revisions

From miki
Jump to navigation Jump to search
No edit summary
(→‎Courier IMAP on Cygwin: moved to a dedicated page)
Line 26: Line 26:


=== Courier IMAP on Cygwin ===
=== Courier IMAP on Cygwin ===
See the page dedicated to [[Courier Cygwin]].

There is no binary package for '''Cygwin'''. And building '''Courier IMAP''' on that platform is a true pain in the neck, if not something else. 2 packages must be built: '''courier-authlib''' and '''courier-imap'''. Some links I found on Internet:
* Building '''courier-authlib'''
** http://readlist.com/lists/cygwin.com/cygwin/1/6668.html
** http://cygwin.com/ml/cygwin/2005-04/threads.html#00614
* Building '''courier-imap'''
** There is a <tt>README.cygwin</tt> that provides some direction on how to build this package on Cygwin.
In summary, this is the furthest I went:
<source lang="bash">
# First, installed these packages in Cygwin: gdbm, libgdbm-devel, minires-devel, libgdbm, libgdbm3, libtool
tar -xvjf courier-authlib-0.61.0.tar.bz2
cd courier-authlib-0.61.0
# Fix Makefile that builds makedatprog
sed -i 's/noinst_PROGRAMS = @makedatprog_target@/noinst_PROGRAMS = @makedatprog_target@$(EXEEXT)/' makedat/Makefile.in
./configure --with-mailuser=SYSTEM --with-mailgroup=SYSTEM --with-db=gdbm
make
# ... ERRORS!
</source>

But... Thierry succeeded in compiling and installing '''Courier-IMAP''' and '''Courier-authlib''' on Cywing. He has detailed the complete procedure on [[http://wiki.yobi.be/wiki/Courier-Cygwin Yobi Wiki]]. Here the exact steps I applied myself

==== Cygwin Packages ====

Install required Cygwin packages (run Cygwin's <tt>setup.exe</tt>):
* <tt>patch</tt>, <tt>tar</tt>, <tt>make</tt>, <tt>gcc</tt>
* <tt>crypt</tt>
* <tt>libgdbm-devel</tt>
* <tt>libtool</tt>
* <tt>inetutils</tt>
* <tt>cygrunsrv</tt>
* <tt>psmisc</tt>

==== Install courier-authlib ====

untar '''courier-authlib'''

<source lang="bash">
tar -xvjf courier-authlib-0.61.0.tar.bz2
cd courier-authlib-0.61.0
</source>

Apply [https://kiwi.noekeon.org/miki/upload/courier-authlib-0.61.0-cygwin.patch this patch]:

<source lang="bash">
patch -Np1 <../courier-authlib-0.61.0-cygwin.patch
</source>

Configure (replace mailuser with an user name from /etc/passwd - I used my own username as suggested), build, check and install.

<source lang="bash">
./configure --disable-root-check --with-waitfunc=wait --without-authpam --without-authldap --without-authpwd \
--without-authshadow --without-authcustom --without-authpipe --without-authmysql --without-authpgsql --with-mailuser=mailuser \
--with-mailgroup=mkgroup-l-d
make
make check
make install
</source>

==== Install courier-imap ====
'''Building and installing courier-imap'''

untar '''courier-imap'''

<source lang="bash">
tar -xvjf courier-imap-4.4.1.tar.bz2
cd courier-imap-4.4.1
</source>

Apply [https://kiwi.noekeon.org/miki/upload/courier-imap-4.4.1-cygwin.patch this patch]:

<source lang="bash">
patch -Np1 <../courier-imap-4.4.1-cygwin.patch
</source>

Configure, build, check and install.

<source lang="bash">
./configure --disable-root-check --with-waitfunc=wait
make
make install
make install-configure
</source>

==== Configuration ====

If not present yet, add <tt>/usr/local/bin</tt> and <tt>/usr/local/sbin</tt> to your path (ideally in <tt>/etc/bash.bashrc</tt>):

<source lang="bash">
PATH=/usr/local/bin:/usr/local/sbin:$PATH
</source>

Create courier-authlib configuration file,

<source lang="bash">
cp /usr/local/etc/authlib/authdaemonrc.dist /usr/local/etc/authlib/authdaemonrc
</source>

and edit its content as follows:

<pre>
# The number of daemon processes that are started.
daemons=3
</pre>

Create user mailbox (replace username with user account name). Repeat for all users:
<source lang="bash">
mkdir -p /home/username #if don't exist yet...
cd /home/username
for i in "" .Drafts .Sent .Trash .Templates; do /usr/lib/courier-imap/bin/maildirmake ~username/MailDir/$i; done
# Create also default Maildir for new users
for i in "" .Drafts .Sent .Trash .Templates; do /usr/lib/courier-imap/bin/maildirmake /etc/skel/MailDir/$i; done
</source>

Create user authentication database:
<source lang="bash">
touch /usr/local/etc/authlib/userdb
chmod 700 /usr/local/etc/authlib/userdb
#Repeat for each username:
pw2userdb | grep "^username">>/usr/local/etc/authlib/userdb # Fill userdb from /etc/passwd user entry
userdb username set mail=~username/MailDir # Specify user MailDir location
userdbpw | userdb username set systempw # Set user account password
...
makeuserdb # Create binary database
</source>

Edit the file <tt>/usr/lib/courier-imap/etc/imapd</tt>:
<pre>
ADDRESS=127.0.0.1 #Typ. use 0 or 127.0.0.1
...
IMAP_ULIMITD=2097152 #Set same value as returned by 'ulimit -v' or imapd.rc will complain
</pre>

Create link to authlib and imap daemon in <tt>/etc/rc.d/init.d</tt>
<source lang="bash">
ln -s /usr/local/sbin/authdaemond /etc/rc.d/init.d/courier-authlib
ln -s /usr/lib/courier-imap/libexec/imapd.rc /etc/rc.d/init.d/courier-imap
</source>

==== Running ====

Start authlib and imap daemon:

<source lang="bash">
/etc/rc.d/init.d/courier-authlib start
/etc/rc.d/init.d/courier-imap start
</source>

==== Testing ====

If not done yet, configure '''syslogd''' for capturing system message from '''courier-authlib'''

<source lang="bash">
syslogd-config #if not configured yet
net start syslogd #if not started yet
</source>

Edit courier-authlib configuration file <tt>/usr/local/etc/authlib/authdaemonrc</tt>to enable full debug message:

<pre>
# DEBUG_LOGIN=2 - turn on debugging + log passwords too
DEBUG_LOGIN=2
</pre>

and restart ''authdaemond'' to enable debug logging:

<source lang="bash">
/etc/rc.d/init.d/courier-authlib stop
/etc/rc.d/init.d/courier-authlib start
</source>

Testing authlib (replace <tt>CCCCCC</tt> with your password:
<pre>
$ export PATH=$PATH:/usr/local/lib/bin #because authtest needs a library there (strace authtest
$ authtest username CCCCCC
</pre>

Output must be similar to
<pre>
Authentication succeeded.

Authenticated: username (uid 1001, gid 10545)
Home Directory: /home/username
Maildir: /home/username/Maildir
Quota: (none)
Encrypted Password: XXXXXX
Cleartext Password: CCCCCC
Options: (none)
</pre>

Check everything is fine in <tt>/var/log/messages</tt>

Testing courier-imap:
<source lang="bash">
$ telnet localhost 143
</source>
Type the following commands
<pre>
001 LOGIN username password
002 EXAMINE INBOX
003 LOGOUT
</pre>
Server must reply with OK messages (and additionally more information)

When testing is done, don't forget to reset debugging in <tt>/usr/local/etc/authlib/authdaemonrc</tt>:
<pre>
# DEBUG_LOGIN=2 - turn on debugging + log passwords too
DEBUG_LOGIN=0
</pre>

====Install as a service====
TBC

====File location====
* /usr/local/bin
* /usr/local/sbin
* /usr/lib/courier-imap
* /usr/local/etc/authlib

Revision as of 23:20, 6 November 2008

IMAP servers

There are basically three main IMAP server solutions:

UW IMAP
IMAP server developped by the University of Washington. Uses a proprietory mailbox format mbx, which is more or less a binary version of the usual mailbox format. A binary package exists on cygwin, but it regularly suffers from locking problems. A patch exists to use maildir format though, but patch seems outdated.
Courier IMAP
Courier-IMAP is a fast, scalable, enterprise IMAP server that uses Maildirs.
Cyrus IMAP
Developped by Carnegie Mellon. Also uses a private mailbox format.

Courier IMAP

References

Courier IMAP on openSUSE

Binary package for Courier IMAP is available on openSUSE (package courier-authlib and courier-imap). However it conflicts with the default IMAP server, (UW IMAP), which must first be uninstalled.

Courier IMAP on Cygwin

See the page dedicated to Courier Cygwin.