Tested 3/28/2019

1. Stop services

qmailctl stop && systemctl stop dovecot

2. Disable qmt-current repo, enable qmt-md-current, and install QMT multi-domain packages

yum-config-manager --disable qmt-current
wget -O /etc/yum.repos.d/qmt-md.repo  http://www.qmailtoaster.org/qmt-md.repo
yum-config-manager --enable qmt-md-current
yum clean all
yum update dovecot qmail ezmlm ezmlm-cgi vpopmail qmailadmin vqadmin

3. Create new vpopmail database (script)


# This script converts the vpopmail db from a many table format--the table names
# of the form domain_tld (domain.tld)--to one vpopmail table that is similar to 
# the former with the addition of the tld, thus 'many domains'.

# In addition to this vpopmail db conversion appropriate replacement packages
# must be installed to interact with the new sql db here.
# The conversion was necessary to utilize Dovecot's dsync utility, specifically,
# it's requirement for the command `doveadm user '*'` which fails with the 
# vpopmail driver (replaced by sql driver) in the standard QMT installation.


mysql -p$DBPASSWD -D $DB -e "CREATE TABLE vpopmail \
(pw_name char(32) NOT NULL, \
pw_domain char(96) NOT NULL, \
pw_passwd char(40) DEFAULT NULL, \
pw_uid int(11) DEFAULT NULL, \
pw_gid int(11) DEFAULT NULL, \
pw_gecos char(48) DEFAULT NULL, \
pw_dir char(160) DEFAULT NULL, \
pw_shell char(20) DEFAULT NULL,\
pw_clear_passwd char(16) DEFAULT NULL, \
PRIMARY KEY (pw_name,pw_domain)) ENGINE=InnoDB DEFAULT CHARSET=latin1"
[ "$?" != "0" ] && echo "Error creating vpopmail table" && exit 1
for i in `echo "show tables" | mysql -p$DBPASSWD $DB|grep -v Tables_in_`;
        if ! [ $i = dir_control ] && ! [ $i = lastauth ] && ! [ $i = vlog ] && ! [ $i = valias ] && ! [ $i = vpopmail ]; then
                # MySQL does not allow table names with a dot (.) so vpopmail replaces the dot (.) with an underscore (_) for 
                # domain table names, example: table whitehorsetc.com becomes whitehorsetc_com. Vpopmail utilities will not allow 
                # one to create a domain name with an underscore even though RFC allows it. So, we can safely replace all domain 
                # table name underscores (_) with periods or dots (.) (below, 'domain_name') in our conversion for entry into the
                # new vpopmail many domains table.
                domain_name=`echo $i | sed -e 's/\(.*\)_/\1./' -e 's/_/-/g'`
                echo $domain_name;
                mysql -p$DBPASSWD -D $DB -B --skip-column-names -e "INSERT INTO vpopmail SELECT pw_name, '$domain_name', pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell, pw_clear_passwd FROM $i"

Update of pkgs above replaced Dovecot's configs skip to step 6, otherwise step 4 & 5

4. Get SQL driver file

wget -O /etc/dovecot/dovecot-sql.conf.ext http://www.qmailtoaster.org/dovecot-sql.conf.ext

5. Edit '/etc/dovecot/toaster.conf' and replace vpopmail with SQL drivers

Replace vpopmail (red)

passdb {
  args = cache_key=%u%r webmail=
  driver = vpopmail
userdb {
  args = cache_key=%u quota_template=quota_rule=*:backend=%q
  driver = vpopmail

With SQL (green)

passdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf.ext

userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf.ext

6. Start services

qmailctl start && systemctl start dovecot