35     local   mailsys     +mailsys                          md5  | 
    35     local   mailsys     +mailsys                          md5  | 
    36   | 
    36   | 
    37     # reload configuration  | 
    37     # reload configuration  | 
    38     /etc/init.d/postgresql-8.4 force-reload  | 
    38     /etc/init.d/postgresql-8.4 force-reload  | 
    39   | 
    39   | 
    40 * Create a DB user if necessary:  | 
    40 * Create a database superuser if necessary:  | 
    41     DB Superuser:  | 
    41     # as root run: su - postgres  | 
         | 
    42     # if you have sudo privileges run: sudo su - postgres  | 
         | 
    43     # create your superuser, which will be able to create users and databases  | 
    42     createuser -s -d -r -E -e -P $USERNAME  | 
    44     createuser -s -d -r -E -e -P $USERNAME  | 
    43     DB User:  | 
    45   | 
    44     createuser -d -E -e -P $USERNAME  | 
    46 * As superuser create the database and db users for vmm, Postfix and Dovecot  | 
    45   | 
         | 
    46 * Create Database and db users for vmm, Postfix and Dovecot  | 
         | 
    47     connecting to PostgreSQL:  | 
    47     connecting to PostgreSQL:  | 
    48     psql template1  | 
    48     psql template1  | 
    49   | 
    49   | 
    50     # create users, group and the database  | 
    50     # create users, group and the database  | 
    51     CREATE USER vmm ENCRYPTED PASSWORD 'DB PASSWORD for vmm';  | 
    51     CREATE ROLE vmm LOGIN ENCRYPTED PASSWORD 'DB PASSWORD for vmm';  | 
    52     CREATE USER dovecot ENCRYPTED password 'DB PASSWORD for Dovecot';  | 
    52     CREATE ROLE dovecot LOGIN ENCRYPTED password 'DB PASSWORD for Dovecot';  | 
    53     CREATE USER postfix ENCRYPTED password 'DB PASSWORD for Postfix';  | 
    53     CREATE ROLE postfix LOGIN ENCRYPTED password 'DB PASSWORD for Postfix';  | 
    54     CREATE ROLE mailsys WITH USER postfix, dovecot, vmm;  | 
    54     CREATE ROLE mailsys WITH USER postfix, dovecot, vmm;  | 
    55     CREATE DATABASE mailsys WITH OWNER vmm ENCODING 'UTF8';  | 
    55     CREATE DATABASE mailsys WITH OWNER vmm ENCODING 'UTF8';  | 
    56     \q  | 
    56     \q  | 
    57   | 
    57   | 
    58     # connect to the new database  | 
    58     # connect to the new database  | 
    59     psql mailsys vmm -W -h 127.0.0.1  | 
    59     psql mailsys vmm -W -h 127.0.0.1  | 
    60     # either import the database structure for Dovecot v1.0.x/v1.1.x  | 
    60     # either import the database structure for Dovecot v1.0.x/v1.1.x  | 
    61     \i /path/to/create_tables.pgsql  | 
    61     \i vmm-y.x.z/pgsql/create_tables.pgsql  | 
    62     # or import the database structure for Dovecot v1.2.x  | 
    62     # or import the database structure for Dovecot v1.2.x/v2.x  | 
    63     \i /path/to/create_tables-dovecot-1.2.x.pgsql  | 
    63     \i vmm-x.y.z/pgsql/create_tables-dovecot-1.2.x.pgsql  | 
    64   | 
         | 
    65     # set permissions  | 
         | 
    66     GRANT SELECT ON dovecot_password, dovecot_user TO dovecot;  | 
         | 
    67     GRANT SELECT ON postfix_alias, postfix_gid, postfix_maildir,  | 
         | 
    68     postfix_relocated, postfix_transport, postfix_uid TO postfix;  | 
         | 
    69   | 
         | 
    70     # leave psql  | 
    64     # leave psql  | 
    71     \q  | 
    65     \q  | 
         | 
    66   | 
         | 
    67     # set permissions for your Dovecot and Postfix users  | 
         | 
    68     # see python set-permissions.py -h for details  | 
         | 
    69     python vmm-x.y.z/pgsql/set-permissions.py -a -H 127.0.0.1 -U vmm  | 
    72   | 
    70   | 
    73 Create directory for your mails  | 
    71 Create directory for your mails  | 
    74   mkdir /srv/mail  | 
    72   mkdir /srv/mail  | 
    75   cd /srv/mail/  | 
    73   cd /srv/mail/  | 
    76   mkdir 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z  | 
    74   mkdir 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z  | 
    77   chmod 771 /srv/mail  | 
    75   chmod 771 /srv/mail  | 
    78   chmod 751 /srv/mail/*  | 
    76   chmod 751 /srv/mail/*  | 
    79   | 
    77   | 
    80 Configuring Dovecot  | 
    78   | 
         | 
    79 For Dovecot >= 2.0 read the file Configure.Dovecot_2  | 
         | 
    80 Configuring Dovecot v1.x  | 
    81   | 
    81   | 
    82 * /etc/dovecot/dovecot.conf  | 
    82 * /etc/dovecot/dovecot.conf  | 
    83     # all your other settings  | 
    83     # all your other settings  | 
    84     #disable_plaintext_auth = no  | 
    84     #disable_plaintext_auth = no  | 
    85     mail_location = maildir:~/Maildir  | 
    85     mail_location = maildir:~/Maildir  | 
   101         master { | 
   101         master { | 
   102           path = /var/run/dovecot/auth-master  | 
   102           path = /var/run/dovecot/auth-master  | 
   103           mode = 0600  | 
   103           mode = 0600  | 
   104         }  | 
   104         }  | 
   105         client { | 
   105         client { | 
   106           path = /var/spool/postfix/private/auth  | 
   106           path = /var/spool/postfix/private/dovecot-auth  | 
   107           mode = 0660  | 
   107           mode = 0660  | 
   108           user = postfix  | 
   108           user = postfix  | 
   109           group = postfix  | 
   109           group = postfix  | 
   110         }  | 
   110         }  | 
   111       }  | 
   111       }  | 
   112     }  | 
   112     }  | 
   113   | 
   113   | 
   114 * /etc/dovecot/dovecot-sql.conf  | 
   114 * /etc/dovecot/dovecot-sql.conf  | 
   115     driver = pgsql  | 
   115     driver = pgsql  | 
   116     connect = host=localhost dbname=mailsys user=dovecot password=$Dovecot_PASS  | 
   116     connect = host=localhost dbname=mailsys user=dovecot password=$Dovecot_PASS  | 
   117     default_pass_scheme = PLAIN  | 
   117     default_pass_scheme = CRAM-MD5  | 
   118     password_query = SELECT "user", password FROM dovecot_password WHERE "user"='%Lu' AND %Ls  | 
   118     password_query = SELECT userid AS "user", password FROM dovecotpassword('%Ln', '%Ld') WHERE %Ls | 
   119     user_query = SELECT home, uid, gid, mail FROM dovecot_user WHERE userid = '%Lu'  | 
   119     user_query = SELECT home, uid, gid, mail FROM dovecotuser('%Ln', '%Ld') | 
   120   | 
   120   | 
   121 Provide a root SETUID copy of Dovecot's deliver agent for Postfix  | 
   121 Provide a root SETUID copy of Dovecot's deliver agent for Postfix  | 
         | 
   122   | 
         | 
   123 /!\ Only required with Dovecot v.1.x.  | 
         | 
   124     With Dovecot >= v2.0 use Dovecot's lmtp!  | 
   122   | 
   125   | 
   123     mkdir -p /usr/local/lib/dovecot  | 
   126     mkdir -p /usr/local/lib/dovecot  | 
   124     chmod 700 /usr/local/lib/dovecot  | 
   127     chmod 700 /usr/local/lib/dovecot  | 
   125     chown nobody /usr/local/lib/dovecot  | 
   128     chown nobody /usr/local/lib/dovecot  | 
   126     cp /usr/lib/dovecot/deliver /usr/local/lib/dovecot/  | 
   129     cp /usr/lib/dovecot/deliver /usr/local/lib/dovecot/  | 
   131   | 
   134   | 
   132 Start or restart Dovecot  | 
   135 Start or restart Dovecot  | 
   133   | 
   136   | 
   134   | 
   137   | 
   135 Configuring Postfix's master.cf  | 
   138 Configuring Postfix's master.cf  | 
   136   | 
   139       | 
         | 
   140 /!\ Only required with Dovecot v.1.x.  | 
   137     # Add Dovecot's deliver agent  | 
   141     # Add Dovecot's deliver agent  | 
   138     dovecot   unix  -       n       n       -       -       pipe  | 
   142     dovecot   unix  -       n       n       -       -       pipe  | 
   139       flags=DORhu user=nobody argv=/usr/local/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop} -n -m ${extension} | 
   143       flags=DORhu user=nobody argv=/usr/local/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop} -n -m ${extension} | 
   140   | 
   144   | 
   141   | 
   145   | 
   142   | 
   146   | 
   143 Configuring Postfix's main.cf  | 
   147 Configuring Postfix's main.cf  | 
   144     # relocated users from the database  | 
   148     # relocated users from the database  | 
   145     #relocated_maps = pgsql:/etc/postfix/pgsql-relocated_maps.cf  | 
   149     #relocated_maps = pgsql:/etc/postfix/pgsql-relocated_maps.cf  | 
   146   | 
   150   | 
         | 
   151     # transport settings from our database  | 
         | 
   152     transport_maps = pgsql:/etc/postfix/pgsql-transport_maps.cf  | 
         | 
   153   | 
   147     # virtual domains  | 
   154     # virtual domains  | 
   148     virtual_mailbox_domains = pgsql:/etc/postfix/pgsql-virtual_mailbox_domains.cf  | 
   155     virtual_mailbox_domains = pgsql:/etc/postfix/pgsql-virtual_mailbox_domains.cf  | 
   149     virtual_alias_maps = pgsql:/etc/postfix/pgsql-virtual_alias_maps.cf  | 
   156     virtual_alias_maps = pgsql:/etc/postfix/pgsql-virtual_alias_maps.cf  | 
   150     transport_maps = pgsql:/etc/postfix/pgsql-transport.cf  | 
         | 
   151     virtual_minimum_uid = 70000  | 
   157     virtual_minimum_uid = 70000  | 
   152     virtual_uid_maps = pgsql:/etc/postfix/pgsql-virtual_uid_maps.cf  | 
   158     virtual_uid_maps = pgsql:/etc/postfix/pgsql-virtual_uid_maps.cf  | 
   153     virtual_gid_maps = pgsql:/etc/postfix/pgsql-virtual_gid_maps.cf  | 
   159     virtual_gid_maps = pgsql:/etc/postfix/pgsql-virtual_gid_maps.cf  | 
   154     virtual_mailbox_base = /  | 
   160     virtual_mailbox_base = /  | 
   155     virtual_mailbox_maps = pgsql:/etc/postfix/pgsql-virtual_mailbox_maps.cf  | 
   161     virtual_mailbox_maps = pgsql:/etc/postfix/pgsql-virtual_mailbox_maps.cf  | 
   156   | 
   162   | 
   157     # dovecot LDA  | 
   163     # dovecot LDA (only recommended with Dovecot v1.x)  | 
   158     dovecot_destination_recipient_limit = 1  | 
   164     #dovecot_destination_recipient_limit = 1  | 
   159     virtual_transport = dovecot:  | 
   165     #virtual_transport = dovecot:  | 
         | 
   166   | 
         | 
   167     # dovecot lmtp  | 
         | 
   168     virtual_transport = lmtp:unix:private/dovecot-lmtp  | 
   160   | 
   169   | 
   161     # dovecot SASL  | 
   170     # dovecot SASL  | 
   162     smtpd_sasl_type = dovecot  | 
   171     smtpd_sasl_type = dovecot  | 
   163     smtpd_sasl_path = private/auth  | 
   172     smtpd_sasl_path = private/dovecot-auth  | 
   164     smtpd_sasl_auth_enable = yes  | 
   173     smtpd_sasl_auth_enable = yes  | 
   165     # Keep smtpd_sasl_local_domain identical to Dovecot's auth_default_realm:  | 
   174     # Keep smtpd_sasl_local_domain identical to Dovecot's auth_default_realm:  | 
   166     # empty. Both are empty by default. Let it commented out.  | 
   175     # empty. Both are empty by default. Let it commented out.  | 
   167     # Read more at: http://wiki.dovecot.org/Authentication/Mechanisms/DigestMD5  | 
   176     # Read more at: http://wiki.dovecot.org/Authentication/Mechanisms/DigestMD5  | 
   168     #smtpd_sasl_local_domain =  | 
   177     #smtpd_sasl_local_domain =  | 
   176       reject_unauth_destination  | 
   185       reject_unauth_destination  | 
   177   | 
   186   | 
   178   | 
   187   | 
   179 Installing the Virtual Mail Manager and configure the rest  | 
   188 Installing the Virtual Mail Manager and configure the rest  | 
   180   | 
   189   | 
   181     Installing from Mercurial or vmm-x.y.z.tar.bz2  | 
   190     Installing from Mercurial or vmm-x.y.z.tar.gz  | 
   182     after cloning from the hg repo or extracting the archive change into the  | 
   191     after cloning from the hg repo or extracting the archive change into the  | 
   183     new directory and type:  | 
   192     new directory and type:  | 
   184         ./install.sh  | 
   193         ./install.sh  | 
   185     edit all the pgsql-*.cf files in /etc/postfix  | 
   194     edit all the pgsql-*.cf files in /etc/postfix  | 
   186   | 
   195   | 
   187     reload postfix  | 
   196     reload postfix  | 
   188   | 
   197   | 
   189     # configure the Virtual Mail Manager  | 
   198     # configure the Virtual Mail Manager  | 
         | 
   199     # vmm.cfg(5) - configuration file for vmm  | 
         | 
   200     #  | 
         | 
   201     # For Dovecot v1.x use 'dovecot:' as domain.transport  | 
         | 
   202     # When using Dovecot v2.x use 'lmtp:unix:private/dovecot-lmtp' as  | 
         | 
   203     # domain.transport  | 
   190     vmm configure  | 
   204     vmm configure  | 
   191   | 
   205   | 
   192     # for help type  | 
   206     # for help type  | 
         | 
   207     # vmm(1) - command line tool to manage email domains/accounts/aliases  | 
   193     vmm help  | 
   208     vmm help  | 
   194   | 
   209   |