| 
     1 Installation Prerequisites  | 
         | 
     2 You should already have installed and configured Postfix, Dovecot and  | 
         | 
     3 PostgreSQL.  | 
         | 
     4 You have to install Python and pyPgSQL to use the Virtual Mail Manager.  | 
         | 
     5   | 
         | 
     6   | 
         | 
     7 Configuring PostgreSQL  | 
         | 
     8   | 
         | 
     9 * /etc/postgresql/8.2/main/pg_hba.conf  | 
         | 
    10     # IPv4 local connections:  | 
         | 
    11     host    mailsys     +mailsys    127.0.0.1/32          md5  | 
         | 
    12   | 
         | 
    13     # reload configuration  | 
         | 
    14     /etc/init.d/postgresql-8.2 force-reload  | 
         | 
    15   | 
         | 
    16 * Create a DB user if necessary:  | 
         | 
    17     DB Superuser:  | 
         | 
    18     createuser -s -d -r -E -e -P $USERNAME  | 
         | 
    19     DB User:  | 
         | 
    20     createuser -d -E -e -P $USERNAME  | 
         | 
    21   | 
         | 
    22 * Create Database and db users for Postfix and Dovecot  | 
         | 
    23     connecting to PostgreSQL:  | 
         | 
    24     psql template1  | 
         | 
    25       | 
         | 
    26     # create database  | 
         | 
    27     CREATE DATABASE mailsys ENCODING 'UTF8';  | 
         | 
    28     # connect to the new database  | 
         | 
    29     \c mailsys  | 
         | 
    30     # import db structure  | 
         | 
    31     \i /path/to/create_tables.pgsql  | 
         | 
    32   | 
         | 
    33     # create users and group  | 
         | 
    34     CREATE USER postfix ENCRYPTED password 'DB PASSWORD for Postfix';  | 
         | 
    35     CREATE USER dovecot ENCRYPTED password 'DB PASSWORD for Dovecot';  | 
         | 
    36     CREATE ROLE mailsys WITH USER postfix, dovecot;  | 
         | 
    37   | 
         | 
    38     # set permissions  | 
         | 
    39     GRANT SELECT ON dovecot_password, dovecot_user TO dovecot;  | 
         | 
    40     GRANT SELECT ON postfix_alias, postfix_maildir, postfix_relocated,  | 
         | 
    41     postfix_uid, postfix_gid, postfix_transport TO postfix;  | 
         | 
    42   | 
         | 
    43     # leave psql  | 
         | 
    44     \q  | 
         | 
    45   | 
         | 
    46 Create directory for your mails  | 
         | 
    47   mkdir /srv/mail  | 
         | 
    48   cd /srv/mail/  | 
         | 
    49   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  | 
         | 
    50   chmod 771 /srv/mail  | 
         | 
    51   chgrp -R mail /srv/mail  | 
         | 
    52   chmod 751 /srv/mail/*  | 
         | 
    53   | 
         | 
    54 Configuring Dovecot  | 
         | 
    55   | 
         | 
    56 * /etc/dovecot/dovecot.conf  | 
         | 
    57     # all your other settings  | 
         | 
    58     mail_location = maildir:~/Maildir  | 
         | 
    59     mail_extra_groups = mail  | 
         | 
    60     first_valid_uid = 70000  | 
         | 
    61     first_valid_gid = 70000  | 
         | 
    62     protocol lda { | 
         | 
    63       postmaster_address = postmaster@domain.tld  | 
         | 
    64     }  | 
         | 
    65     auth default { | 
         | 
    66       mechanisms = cram-md5  | 
         | 
    67       passdb sql { | 
         | 
    68         args = /etc/dovecot/dovecot-sql.conf  | 
         | 
    69       }  | 
         | 
    70       userdb sql { | 
         | 
    71         args = /etc/dovecot/dovecot-sql.conf  | 
         | 
    72       }  | 
         | 
    73       user = nobody  | 
         | 
    74       socket listen { | 
         | 
    75         master { | 
         | 
    76           path = /var/run/dovecot/auth-master  | 
         | 
    77           mode = 0600  | 
         | 
    78         }  | 
         | 
    79         client { | 
         | 
    80           path = /var/spool/postfix/private/auth  | 
         | 
    81           mode = 0660  | 
         | 
    82           user = postfix  | 
         | 
    83           group = postfix  | 
         | 
    84         }  | 
         | 
    85       }  | 
         | 
    86     }  | 
         | 
    87   | 
         | 
    88 * /etc/dovecot/dovecot-sql.conf  | 
         | 
    89     driver = pgsql  | 
         | 
    90     connect = host=localhost dbname=mailsys user=dovecot password=$Dovecot_PASS  | 
         | 
    91     default_pass_scheme = HMAC-MD5  | 
         | 
    92     password_query = SELECT "user", password FROM dovecot_password WHERE "user"= '%u'  | 
         | 
    93     user_query = SELECT home, uid, gid FROM dovecot_user WHERE userid = '%u'  | 
         | 
    94   | 
         | 
    95 Provide a root SETUID copy of Dovecot's deliver agent for Postfix  | 
         | 
    96   | 
         | 
    97     mkdir -p /usr/local/lib/dovecot  | 
         | 
    98     chmod 700 /usr/local/lib/dovecot  | 
         | 
    99     chown nobody /usr/local/lib/dovecot  | 
         | 
   100     cp /usr/lib/dovecot/deliver /usr/local/lib/dovecot/  | 
         | 
   101     chmod u+s /usr/local/lib/dovecot/deliver  | 
         | 
   102   | 
         | 
   103   | 
         | 
   104 Start or restart Dovecot  | 
         | 
   105   | 
         | 
   106   | 
         | 
   107 Configuring Postfix's master.cf  | 
         | 
   108   | 
         | 
   109     # Add Dovecot's deliver agent  | 
         | 
   110     dovecot   unix  -       n       n       -       -       pipe  | 
         | 
   111       flags=DRhu user=nobody:mail argv=/usr/local/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop} -n -m ${extension} | 
         | 
   112   | 
         | 
   113   | 
         | 
   114   | 
         | 
   115 Configuring Postfix's main.cf  | 
         | 
   116   | 
         | 
   117     # virtual domains  | 
         | 
   118     virtual_mailbox_domains = pgsql:/etc/postfix/pgsql-transport.cf  | 
         | 
   119     virtual_alias_maps = pgsql:/etc/postfix/pgsql-virtual_alias_maps.cf  | 
         | 
   120     transport_maps = pgsql:/etc/postfix/pgsql-transport.cf  | 
         | 
   121     virtual_minimum_uid = 70000  | 
         | 
   122     virtual_uid_maps = pgsql:/etc/postfix/pgsql-virtual_uid_maps.cf  | 
         | 
   123     virtual_gid_maps = pgsql:/etc/postfix/pgsql-virtual_gid_maps.cf  | 
         | 
   124     virtual_mailbox_base = /  | 
         | 
   125     virtual_mailbox_maps = pgsql:/etc/postfix/pgsql-virtual_mailbox_maps.cf  | 
         | 
   126   | 
         | 
   127     # dovecot LDA  | 
         | 
   128     dovecot_destination_recipient_limit = 1  | 
         | 
   129     virtual_transport = dovecot:  | 
         | 
   130   | 
         | 
   131     # dovecot SASL  | 
         | 
   132     smtpd_sasl_type = dovecot  | 
         | 
   133     smtpd_sasl_path = private/auth  | 
         | 
   134     smtpd_sasl_auth_enable = yes  | 
         | 
   135     smtpd_sasl_local_domain = $myhostname  | 
         | 
   136     smtpd_sasl_security_options = noplaintext, noanonymous  | 
         | 
   137   | 
         | 
   138   | 
         | 
   139   | 
         | 
   140 Installing the Virtual Mail Manager and configure the rest  | 
         | 
   141   | 
         | 
   142     Installing from SVN  | 
         | 
   143     after checking out type  | 
         | 
   144         ./install  | 
         | 
   145     edit all the pgsql-*.cf files in /etc/postfix  | 
         | 
   146   | 
         | 
   147     reload postfix  | 
         | 
   148   | 
         | 
   149     # configure the Virtual Mail Manager  | 
         | 
   150     vmm configure  | 
         | 
   151   | 
         | 
   152     # for help type  | 
         | 
   153     vmm help  | 
         | 
   154   |