Make Dovecot Work for You
Installing dovecot on your personal ubuntu machine
arpepper@cscfpc20:~$ sudo apt-get install dovecot-imapd
Checking the version of dovecot you got
arpepper@dovecot:~ dovecot --version
1.2.9
arpepper@dovecot:~
Or you might need the following, or possibly even a variation.
arpepper@dovecot:~ /usr/sbin/dovecot --version
1.2.9
arpepper@dovecot:~
Versions of
dovecot from
ubuntu
vary. With the introduction of
dovecot 2.0 the syntax of the already arcane config files changed.
dovecot 2.0 does not seem to have been packaged for
ubuntu
yet.
Presumably because it would make so much documented stuff not work.
Well, actually it might work, but would generate log file diagnostics
indicating the new syntax which should be used.
19 Oct 2012 - ubuntu
is
now providing version 2, but I have not had the energy to change the
tense of this entire page.
A major change affecting these examples is you must use
/usr/lib/dovecot/imap -c ~/dovecot/dovecot.conf
in place of the old
/usr/sbin/dovecot -c ~/dovecot/dovecot.conf --exec-mail imap
Running Dovecot with Alternate Config Files
arpepper@cscfpc20:~$ sudo dovecot -c mypath/myconf.conf
E.g.
arpepper@cscfpc20:~$ sudo /usr/sbin/dovecot -c ~/dovecot/dovecot.conf
Running Dovecot Pre-authenticated
This use of
dovecot
is reasonably equivalent to the
rimapd facility
which used to be provided as part of older
imap server software.
arpepper@cscfpc20:~$ /usr/sbin/dovecot --exec-mail imap
E.g.
arpepper@cscfpc20:~$ ssh -x dovecot.cscf -l arpepper /usr/sbin/dovecot --exec-mail imap
* PREAUTH [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH] Logged in as arpepper
0 logout
* BYE Logging out
0 OK Logout completed.
arpepper@cscfpc20:~$
Or, use your own config file too...
arpepper@cscfpc20:~$ ssh -x dovecot.cscf.uwaterloo.ca -l arpepper /usr/sbin/dovecot -c /u/arpepper/dovecot.cscf/dovecot1.conf --exec-mail imap
* PREAUTH [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH] Logged in as arpepper
0 logout
* BYE Logging out
0 OK Logout completed.
arpepper@cscfpc20:~$
If you are using
dovecot 2
, then you call the
imap
directly, instead of
the above.
See
arpepper@cscfpc20:~$ ssh -x dovecot.cscf -l arpepper /usr/lib/dovecot/imap -c /u/arpepper/dovecot.cscf/dovecot1.conf
You want to get your mail client, such as
thunderbird
, to talk to such
sessions.
mutt
(Mail User Tool) can do that reasonably directly.
Running Dovecot as Localhost daemon only
Minimal
dovecot.conf
to use.
base_dir = /home/arpepper/var/run/dovecot1/
protocols = imap
listen = 127.0.0.1
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = mbox:~/mail:INBOX=~/inbox/%u
mail_privileged_group = mail
protocol imap {
}
protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
}
auth default {
mechanisms = plain
passdb pam {
}
userdb passwd {
}
user = root
}
dict {
}
plugin {
}
arpepper@cscfpc20:~$ sudo /usr/sbin/dovecot -c myconf.conf
Will start a server requiring authentication listening on the normal
imap port on
127.0.0.1. You can create arbitrary such local servers
for different purposes. E.g.
127.0.0.2,
127.0.0.3, etc. Or even
addresses like
127.22.33.44. These will be accessible only to users logged
on to the local machine, and will require authentication.
Using a mail client such as
thunderbird
you should now be able to
add a mail account on server
127.0.0.1
or whatever you have chosen.
Multiple such private servers can be used to organize your mail in
various ways.
For each such server you create, you need to specify a different
/var/run directory, or confusion will
result. The directories need to be created. To properly shutdown that
daemon you could do something like...
arpepper@cscfpc20:~$ pf=/home/arpepper/var/run/dovecot1/master.pid
arpepper@cscfpc20:~$ sudo /sbin/start-stop-daemon --stop --quiet --pidfile $pf
Ideally you would create the directories somewhere which, like
/var/run
will be cleared at boot time.
Localhost Daemon without sudo
Minimal
dovecot.conf
to use.
protocols = imap
mail_location = mbox:~/mail:INBOX=~/inbox/%u
mail_privileged_group = mail
protocol imap {
}
auth default {
mechanisms = plain
passdb pam {
}
userdb passwd {
}
user = root
}
dict {
}
plugin {
}
arpepper@cscfpc20:~$ /usr/sbin/dovecot -c myconf.conf --exec-mail imap
* PREAUTH [CAPABILITY IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS] Logged in as arpepper
0 logout
* BYE Logging out
0 OK Logout completed.
arpepper@cscfpc20:~/tmpdir$
That starts a pre-authenticated session on standard input.
Note that at least some of the apparently null blocks are necessary in
order to get imap protocol to work properly.
The trick is to get a mail client such as
thunderbird
to talk to that.
If your machine has the
socket
command installed, you can use that.
arpepper@cscfpc20:~/tmpdir$ /usr/bin/socket -f -l -p '/usr/sbin/dovecot -c myconf.conf --exec-mail imap' -B 127.0.0.1 -s 14446
That command will sit there working as a daemon.
You can then in
thunderbird
specify server
127.0.0.1 as an imap
server, and afterwards go and change the port from
143 to
14446
(an arbitrary number; choose any one which is available).
The problem with that is that anyone who can sign on to your personal
machine can connect to the service, and will be pre-authenticated as you.
If you don't have the
socket
command, you might be able to compile an
equivalent from source. If you have
sudo
privileges, you are better
to use
sudo
to start privileged daemons requiring authentication, rather than use
sudo
to install the
socket
command to later use non-sudo.
The
socket
command is a way, however, to gain access on your local machine
to a mailbox on a remote machine to which you have indirect access. Once
again, however, it leaves a localhost port open for pre-authenticated
connection.
Useful variations on mail_location
Note that
mail_location isn't exactly a variable name;
mail_ is actually
a prefix used to indicate that the variable
location is set for the appropriate
process.
Just mbox
- mail_location = mbox:~/mail:INBOX=/var/mail/%u
You can choose any directory to which you have access instead of
~/mail
.
It may also
be useful to specify somewhere
other than
/var/mail/%u
as inbox (to avoid altering possible actual
inbox).
mbox inbox with maildir folders
- mail_location = maildir:~/.maildir:INBOX=/var/mail/%u
You can choose any directory to which you have access instead of
~/.maildir
. It may also
be useful to specify somewhere
other than
/var/mail/%u
as inbox (to avoid altering possible actual
inbox).
Note that the
mail_location
syntax does not let you specify one
mbox directory and one maildir directory. But you could accomplish
that by running two different
dovecot
servers on your own machine,
or by using the imap
namespace facility as implemented by
dovecot
.
Actually, it's worse than that. Many months ago my mind slipped up when
I gave that faulty example. It actually expects a maildir
structure beneath /var/mail/%u for each user.
To have an mbox INBOX and maildir folders, you must use namespaces.
Specifying Index Location
- mail_location = maildir:~/.maildir:INBOX=/var/mail/%u:INDEX=~/.indexes
Note that a directory structure will be created beneath there with
directories named
.imap created to house the actual indexes themselves.
Namespaces and User databases
base_dir = /home/arpepper/var/run/dovecot9/
protocols = imap
listen = 127.0.0.9
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = mbox:~/nomail:INBOX=~/nomail/%u
namespace private {
inbox = yes
hidden = no
prefix =
}
namespace private {
separator = /
inbox = yes
hidden = no
prefix = "maildir/"
location=maildir:~/.maildir
}
namespace private {
separator = /
inbox = no
hidden = no
prefix = "mbox/"
location = mbox:~/mail:INDEX=~/.dovecot-indexes
}
protocol imap {
}
protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
}
auth default {
mechanisms = plain
passdb pam {
}
userdb passwd-file {
args = /home/arpepper/dovecot/dovecot9/passwdext
}
user = root
}
dict {
}
plugin {
}
arpepper@cscfpc20:~$ cat /home/arpepper/dovecotdovecot9/passwdext
arpepper:x:1002:1002::/home/arpepper:/bin/bash:userdb_mail=mbox:~/my-mail:INBOX=/var/mail/%u:INDEX=~/.my-dovecot-indexes
arpepper@cscfpc20:~$
Timo once claimed to me you could have a userdb return namespaces,
but he did not elaborate sufficiently for me work out how.
Until that detail is determined, creating custom configurations which
mix both maildir and mbox (which would seem to be desirable) would be
problematic.
An "rimapd" approach is (almost) possible.
Silly mistakes that have wasted time for me
- Instead of INDEX I accidentally typed INDEXES (?!)
- INBOX=: instead of INBOX= gets errors trying to create null filename
- (should be no ":" after =)
- Seems you need to exit and restart Thunderbird 3 before a newly-created folder is visible as a "copy" target in message selection area
Silly realities that weren't my mistakes that have wasted time for me
- cannot subscribe to top-level of a Maildir namespace
- mbox namespace appears to need one folder pre-created?
- Thunderbird does not add newly-created folder to "Copy/Move message to" menu until after you exit and restart
- took a while to track down http://www.dovecot.org/list/dovecot/2010-November/054791.html
--
AdrianPepper - 15 Mar 2011
--
AdrianPepper - 19 Oct 2012
--
AdrianPepper - 20 Mar 2013