Nethence Documentation Lab Webmail Your IP BBDock  


Those documents are obsolete, please use the Nethence Documentation instead.

HomeUnixWindowsOracleObsoleteHardwareDIYMechanicsScriptsConfigsPrivate

Setting up Dovecot v2 for local users and Maildir
on netbsd 7
 
http://pbraun.nethence.com/unix/mail/postfix.html
http://pbraun.nethence.com/unix/mail/dovecot.html
 
Installation
Make sure dovecot v2 is installed,
wget --quiet -O - "$PKG_PATH" | grep dovecot
pkg_add dovecot-2.2.18nb2 
pkg_info | grep dovecot
dovecot --version
cp /usr/pkg/share/examples/rc.d/dovecot /etc/rc.d/
cd /etc/
ln -s /usr/pkg/etc/dovecot
Note. dovecot and dovenull groups are created
Note. dovecot and dovenull users are created
 
Dovecot doesn't like time changes (http://wiki.dovecot.org/TimeMovedBackwards). You need the NTP daemon to slow down or accelerate the clock speed when updating the time.
cd /etc/
cp ntp.conf ntp.conf.dist
echo ntpd=YES >> /etc/rc.conf
service ntpd start
 
Configuration
Setup Dovecot without SSL first,
cd /etc/dovecot/
dovecot -n > dovecot.conf.new
cp dovecot.conf dovecot.conf.dist
mkdir .trash/
mv * .trash/
mv .trash/mkcert.sh .
cp .trash/dovecot.conf.new dovecot.conf
vi dovecot.conf
disable_plaintext_auth = no
mail_location = maildir:~/Maildir
mail_privileged_group = mail
protocols = imap lmtp
#protocols = imaps lmtp
ssl = no
#ssl_cert_file = /chemin/vers/votre/certificat/ssl
#ssl_key_file = /chemin/vers/votre/clé/ssl
Ref. http://wiki.dovecot.org/BasicConfiguration
 
We are using ~/Maildir/ and not /var/mail, but just in case. On netbsd, this is not needed as the /var/mail/ folder has a sticky bit, hence Dovecot can write its lock file in it. But on other systems this might be useful,
cd /var/
ls -al mail/
chgrp -R mail mail/
and,
cd /etc/dovecot/conf.d/
vi 10-mail.conf
mail_privileged_group = mail
 
Review the configuration,
dovecot -n
 
Use procmail to convert mbox to Maildir
Setup procmail system-wide,
echo $PKG_PATH
pkg_add procmail
cd /etc/
ln -s /usr/pkg/etc/procmailrc
vi procmailrc
ORGMAIL=${HOME}/Maildir/
DEFAULT=${ORGMAIL}
 
Reprocess old mboxes,
cd /var/mail/
ls -l
find ~mailuser/Maildir/
procmail -Y -d mailuser < mailuser && rm -f mailuser 
find ~mailuser/Maildir/
Note. not sure -Y is mandatory, but it has proven to be very useful to me on other occasions.
 
Ready to go
Increase the fd limit in the init script,
vi /etc/rc.d/dovecot
768 --> 1000
service dovecot restart
 
Enable the daemon,
echo dovecot=YES >> /etc/rc.conf
service dovecot start
 
And make sure it is running,
ps aux | grep dove
netstat -an -f inet,inet6 | grep 143
 
Eventually test IMAP auth by telnet if SSL hasn't been enabled,
tail -F /var/log/maillog
telnet 127.0.0.1 143
a login user wrong_pass 
a login user good_pass 
a logout
 
Maintenance
Clean-up subscriptions,
cd /var/spool/virtual/example.net/user.imap
for dir in `find . -type d -name .imap`; do rm -rf $dir; done
 
Troubbleshooting
If you get this warning when trying to start the daemon,
Warning: fd limit (ulimit -n) is lower than required under max. load (768 < 1000), because of default_client_limit
==> increase the limit in the init script, see above.
 
Similar case (maybe dovecot 1 msg),
Warning: fd limit 128 is lower than what Dovecot can use under full load (more than 640). Either grow the limit or change login_max_processes_count and max_mail_processes settings
==> increase the amount of file descriptors than can be opened at once in the init script (ulimit -n 1024).
 
If you get those errors,
Error: User initialization failed: Namespace '': Mail storage autodetection failed with home=/home/mailuser
Error: Invalid user settings. Refer to server log for more information.
==> make sure the smtp delivers into the right place and fix mail_location.
 
References -- General
Préparation et configuration de dovecot
How to configure postfix + dovecot to copy and forward?
==> http://neranjara.org/article/title/How_to_configure_PostFix_and_Dovecot_for_Virtual_Users_with_out_a_Database_ (dead link)
Dovecot
Running Dovecot
 
References -- Local and Virtual Users
Basic Configuration
Mail location
Maildir configuration
Virtual Users
User Databases
 
References -- Upgrading
Upgrading Dovecot v1.0 to v1.1
Note. Dovecot 1.0 didn't need username_format=%n.
Upgrading Dovecot v1.1 to v1.2
Note. Dovecot 1.2 had ssl_disable=yes instead of ssl=no.
Note. For Dovecot 1.2 login_greeting_capability is enabled by default.
Upgrading Dovecot v1.2 to v2.0
 

Last update: Dec 20, 2015