Mar 222016

When you have webmail separated from your pop3/imap4 server things can be complicated if you don’t have direct access to mysql server over the network. using poppassd will not solving the problem if you’re using mysql, pgsql or ldap backend for storing user information. because (AFAIK) it only can access/change user/password on passwd/shadow file.

using courierpassd allows us to access or modify pop3/imap4 user information store in mysql, pgsl or ldap backend. one caveat, courierpassd using courier-authlib API in order to be able accessing those database backend. we have to install or build from source. courierpassd use the same protocol as poppassd does.

i’m using centos and this is how i do it.

first using non priviledged user cccount, create rpm build environment.

$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386

echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros

download courier-authlib and courierpassd source

wget -O courierpassd.1.1.2.tar.gz

compile and install courier-authlib

$rpmbuild -ta courier-authlib-0.60.2.tar.bz2
$sudo rpm -ivh /home/youruser/rpm/RPMS/x86_64/courier-authlib-0.66.4-1.el6.x86_64.rpm
$sudo rpm -ivh /home/youruser/rpm/RPMS/x86_64/courier-authlib-devel-0.66.4-1.el6.x86_64.rpm
$sudo rpm -ivh /home/youruser/rpm/RPMS/x86_64/courier-authlib-mysql-0.66.4-1.el6.x86_64.rpm

extract courierpassd, compile and install

#tar xzf courierpassd.1.1.2.tar.gz
#cd courierpassd-1.1.2
#make install

you want be able to access this courierpassd from other server on the network. people using xinet.d usually.

#vi /etc/xinetd.d/courierpassd
service courierpassd
       disable          = no
       socket_type      = stream
       protocol         = tcp
       port             = 106
       wait             = no
       user             = root
       server           = /usr/sbin/courierpassd
       instances        = 10
       only_from        =

now, this is the most important thing!. if you’re not modify this services file couerirpassd will not run through xinet.d.

#vi /etc/services
change port 106 to courierpassd

courierpassd    106/tcp                         # Eudora
courierpassd    106/udp                         # Eudora

restart xinet.d daemon

#service xinetd restart

this is not over yet, you want courierpassd be able to talk to database backend using courier-authlib API.

edit authdaemonrc file

#vi /etc/authlib/authdaemonrc
authmodulelistorig="authuserdb authpam authpgsql authldap authmysql authsqlite authcustom authpipe"

edit authmysqlrc, or pgsql/ldap if you’re using those backend

#vi /etc/authlib/authmysqlrc
MYSQL_SERVER            localhost
MYSQL_USERNAME          postfix
MYSQL_PASSWORD          password
MYSQL_PORT              3306
MYSQL_OPT               0
MYSQL_DATABASE          postfix
MYSQL_USER_TABLE        mailbox
MYSQL_UID_FIELD         '101'
MYSQL_GID_FIELD         '12'
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        '/data/vmail'
MYSQL_NAME_FIELD        name

start courier-authlib daemon

service start courier-authlib

now time to test, telnet your courierpassd daemon from another server, in my case i’ve allowing access from in xinet.d.

# telnet 106
Connected to
Escape character is '^]'.
200 courierpassd v1.1.2 hello, who are you?
200 Your password please.
pass oldpassword
200 Your new password please.
newpass newpassword
200 Password changed, thank-you.
200 Bye.
Connection closed by foreign host.

that’s it 🙂

i forgot to mention how to configure change_pass plugin in squirrelmail

edit config.php in change_pass directory

    // The default server is the configured IMAP server
    $poppass_server = '';

    // The default port is 106
    $poppass_port = 106;

    $min_pass_length = 0;
    $max_pass_length = 9999999;

now you can change your mail password all days if you want 😀

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>