IMAP: Difference between revisions
(→Courier IMAP: Moved on own page) |
|||
(14 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
; [http://www.washington.edu/imap/ UW IMAP] |
; [http://www.washington.edu/imap/ 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. |
: 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|Courier IMAP]] |
||
: Courier-IMAP is a fast, scalable, enterprise IMAP server that uses ''Maildirs''. |
: Courier-IMAP is a fast, scalable, enterprise IMAP server that uses ''Maildirs''. |
||
; [http://cyrusimap.web.cmu.edu/ Cyrus IMAP] |
; [http://cyrusimap.web.cmu.edu/ Cyrus IMAP] |
||
: Developped by Carnegie Mellon. Also uses a private mailbox format. |
: Developped by Carnegie Mellon. Also uses a private mailbox format. |
||
;[[Dovecot|Dovecot IMAP]] |
|||
: A very fast IMAP server focusing on security, which supports mbox and Maildir. |
|||
== |
== Synchronizing IMAP == |
||
=== |
=== offlineimap === |
||
'''offlineimap''' allows you to read the same mailbox from multiple computers and ensures that your changes will be automatically reflected on all computers.<br> |
|||
* [http://www.courier-mta.org/imap/ Courier IMAP homepage] |
|||
See Yoni's page at [http://wiki.yobi.be/wiki/Offlineimap]. |
|||
** [http://www.courier-mta.org/maildir.html maildir - E-mail directory] |
|||
** [http://www.courier-mta.org/FAQ.html Courier FAQ] |
|||
* On ''openSUSE'', check package documentation at <tt>/usr/share/doc/packages/courier-authlib</tt> and <tt>/usr/share/doc/packages/courier-imap</tt>. |
|||
* Manpages & package documentation: |
|||
** [http://www.courier-mta.org/maildirmake.html maildirmake(1)] |
|||
** couriertcpd(1) |
|||
** imapd(8) |
|||
** userdb(8) |
|||
** makeuserdb(8) |
|||
** <tt>/usr/share/doc/courier-doc</tt> (on Ubuntu, with package '''courier-doc''' installed) |
|||
=== |
=== imapsync === |
||
'''imapsync''' is very easy to use to migrate from one mailbox to another. The procedure here is based on the one given here [http://www.howtoforge.com/how-to-migrate-mailboxes-between-imap-servers-with-imapsync] |
|||
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 === |
|||
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"> |
<source lang="bash"> |
||
# Migrating from me@host1.com to me@host2.com |
|||
# First, installed these packages in Cygwin: gdbm, libgdbm-devel, minires-devel, libgdbm, libgdbm3, libtool |
|||
echo 'password' > pwd1 # We hide the password in files so that they don't appear with the command "ps aux" |
|||
tar -xvjf courier-authlib-0.61.0.tar.bz2 |
|||
echo 'password' > pwd2 |
|||
cd courier-authlib-0.61.0 |
|||
chmod 600 pwd1 |
|||
# Fix Makefile that builds makedatprog |
|||
chmod 600 pwd2 |
|||
sed -i 's/noinst_PROGRAMS = @makedatprog_target@/noinst_PROGRAMS = @makedatprog_target@$(EXEEXT)/' makedat/Makefile.in |
|||
imapsync --host1 host1.com --user1 me@host1.com --passfile1 pwd2 --host2 host2.com --user2 me@host2.com --passfile2 pwd2 |
|||
./configure --with-mailuser=SYSTEM --with-mailgroup=SYSTEM --with-db=gdbm |
|||
rm -f pwd1 |
|||
make |
|||
rm -f pwd2 |
|||
# ... ERRORS! |
|||
</source> |
</source> |
||
However it seems that '''imapsync''' is one-way only, and so not suitable for syncing live the same mailbox between several computers [http://www.zimbra.com/forums/migration/13702-imapsync-both-ways.html].<br> |
|||
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 |
|||
For this purpose, better use '''offlineimap'''. |
|||
== Testing IMAP == |
|||
=== Tools === |
|||
Simply use tool like '''telnet''' to connect to the IMAP server. Or equivalently use '''netcat''' or '''socat''': |
|||
Install required Cygwin packages (run Cygwin's <tt>setup.exe</tt>): |
|||
<source lang=bash> |
|||
* <tt>patch</tt>, <tt>tar</tt>, <tt>make</tt>, <tt>gcc</tt> |
|||
% telnet server 143 |
|||
* <tt>crypt</tt> |
|||
% nc server 143 |
|||
* <tt>libgdbm-devel</tt> |
|||
% socat - TCP:server:143 |
|||
* <tt>libtool</tt> |
|||
* <tt>inetutils</tt> |
|||
* <tt>cygrunsrv</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> |
</source> |
||
'''!!! Problem when connecting to Microsoft servers !!!''' - These servers explicitly require <tt>CRLF</tt> as line-terminator, not <tt>CR</tt> as sent by Linux tools. Only workaround so far is to connect through a windows '''telnet'''. |
|||
Apply [https://kiwi.noekeon.org/miki/upload/courier-authlib-0.61.0-cygwin.patch this patch]: |
|||
=== Scripts === |
|||
<source lang="bash"> |
|||
Here some [http://documents.made-it.com/imapcmd.html scripts] to test that an IMAP server is working properly. |
|||
patch -Np1 <../courier-authlib-0.61.0-cygwin.patch |
|||
</source> |
|||
* To quickly test an imap server using telnet use: |
|||
Configure (replace mailuser with an user name from /etc/passwd - I used my own username as suggested), build, check and install. |
|||
<div style="padding-left:2em;"><source lang=bash> |
|||
% telnet server 143 |
|||
<source lang="bash"> |
|||
01 LOGIN username password |
|||
./configure --disable-root-check --with-waitfunc=wait --without-authpam --without-authldap --without-authpwd \ |
|||
02 LIST "" * # show all available mailboxes |
|||
--without-authshadow --without-authcustom --without-authpipe --without-authmysql --without-authpgsql --with-mailuser=mailuser \ |
|||
03 SELECT mailbox # mailbox: e.g. INBOX |
|||
--with-mailgroup=mkgroup-l-d |
|||
04 LOGOUT |
|||
make |
|||
</source></div> |
|||
make check |
|||
* To show the information about a mailbox: |
|||
make install |
|||
<div style="padding-left:2em;"><source lang=bash> |
|||
</source> |
|||
% telnet server 143 |
|||
04 STATUS mailbox (MESSAGES) |
|||
==== Install courier-imap ==== |
|||
</source></div> |
|||
'''Building and installing courier-imap''' |
|||
:Between <tt>()</tt> you can place one or more of the following: <tt>MESSAGES, UNSEEN, RECENT UIDNEXT UIDVALIDITY</tt> |
|||
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 |
|||
# DEBUG_LOGIN=2 - turn on debugging + log passwords too |
|||
DEBUG_LOGIN=2 |
|||
</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> |
|||
==== Running ==== |
|||
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> |
|||
Start authlib and imap daemon: |
|||
<source lang="bash"> |
|||
authdaemond start |
|||
/usr/lib/courier-imap/libexec/imapd.rc start |
|||
</source> |
|||
==== Testing ==== |
|||
Testing authlib: |
|||
<pre> |
|||
$ export PATH=$PATH:/usr/local/lib/bin #because authtest needs a library there (strace authtest |
|||
$ authtest username CCCCCC |
|||
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> |
|||
* And one of the following commands to view a message (1 is the first message * is wildcard for all): |
|||
'''TO DO:''' |
|||
<div style="padding-left:2em;"><source lang=bash> |
|||
# Use SYSTEM instead of my user account for configure authlib |
|||
05 FETCH 1 ALL # All IMAP headers |
|||
05 FETCH 1 FULL # Full headers and body info |
|||
05 FETCH 1 BODY # Body |
|||
05 FETCH 1 ENVELOPE # Envelope |
|||
05 FETCH * FULL # All email |
|||
</source></div> |
|||
* To fully retrieve a message use: |
|||
'''File location''': |
|||
<div style="padding-left:2em;"><source lang=bash> |
|||
/usr/local/bin |
|||
06 UID fetch 1:1 (UID RFC822.SIZE FLAGS BODY.PEEK[]) |
|||
/usr/local/sbin |
|||
</source></div> |
|||
/usr/lib/courier-imap |
|||
/usr/local/etc/authlib |
|||
== Troubleshooting == |
|||
* Can't connect |
|||
* Configuration file: |
|||
** Frequent mistake is that <tt>~/Maildir</tt> was not created. Create the Maildir directory with: |
|||
** <tt>/etc/courier/</tt> |
|||
<div style="padding-left:4em;"><source lang="bash"> |
|||
su accountname |
|||
maildirmake ~/Maildir |
|||
</source></div> |
Latest revision as of 15:13, 21 February 2011
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.
- Dovecot IMAP
- A very fast IMAP server focusing on security, which supports mbox and Maildir.
Synchronizing IMAP
offlineimap
offlineimap allows you to read the same mailbox from multiple computers and ensures that your changes will be automatically reflected on all computers.
See Yoni's page at [1].
imapsync
imapsync is very easy to use to migrate from one mailbox to another. The procedure here is based on the one given here [2]
# Migrating from me@host1.com to me@host2.com
echo 'password' > pwd1 # We hide the password in files so that they don't appear with the command "ps aux"
echo 'password' > pwd2
chmod 600 pwd1
chmod 600 pwd2
imapsync --host1 host1.com --user1 me@host1.com --passfile1 pwd2 --host2 host2.com --user2 me@host2.com --passfile2 pwd2
rm -f pwd1
rm -f pwd2
However it seems that imapsync is one-way only, and so not suitable for syncing live the same mailbox between several computers [3].
For this purpose, better use offlineimap.
Testing IMAP
Tools
Simply use tool like telnet to connect to the IMAP server. Or equivalently use netcat or socat:
% telnet server 143
% nc server 143
% socat - TCP:server:143
!!! Problem when connecting to Microsoft servers !!! - These servers explicitly require CRLF as line-terminator, not CR as sent by Linux tools. Only workaround so far is to connect through a windows telnet.
Scripts
Here some scripts to test that an IMAP server is working properly.
- To quickly test an imap server using telnet use:
% telnet server 143
01 LOGIN username password
02 LIST "" * # show all available mailboxes
03 SELECT mailbox # mailbox: e.g. INBOX
04 LOGOUT
- To show the information about a mailbox:
% telnet server 143
04 STATUS mailbox (MESSAGES)
- Between () you can place one or more of the following: MESSAGES, UNSEEN, RECENT UIDNEXT UIDVALIDITY
- And one of the following commands to view a message (1 is the first message * is wildcard for all):
05 FETCH 1 ALL # All IMAP headers
05 FETCH 1 FULL # Full headers and body info
05 FETCH 1 BODY # Body
05 FETCH 1 ENVELOPE # Envelope
05 FETCH * FULL # All email
- To fully retrieve a message use:
06 UID fetch 1:1 (UID RFC822.SIZE FLAGS BODY.PEEK[])
Troubleshooting
- Can't connect
- Frequent mistake is that ~/Maildir was not created. Create the Maildir directory with:
su accountname
maildirmake ~/Maildir