So lets start off.. lets download PostfixAdmin. As of writting this you can use the following since its the current version
wget http://high5.net/postfixadmin/download.php?file=postfixadmin-2.1.0.tgz tar zxfv download.php?file=postfixadmin-2.1.0.tgz cd postfixadmin-2.1.0
ok my wget saved it as download.php.... your results may vary
Ok now once its installed we want to import the basic DB layout into mysql. Edit the file if you want to change the user/pass.. but you will have to change it in other files below.. so just take note if you edit it.
mysql -u root < DATABASE_MYSQL.TXT
So that command is the default install of mysql that you didn't set a root password on.. use the -p flag if you did
ok now that the layout is there lets get postfix and dovecot installed. Now the default version of postfix that ships with fedora/centos DOES NOT HAVE MYSQL FUNCTIONALITY BUILT IN. So this will be for centos or rhel you have to install the centos Plus version of it.
wget http://mirror.trouble-free.net/centos/4/centosplus/i386/RPMS/postfix-2.1.5-4.2.RHEL4.mysql.centos4.i386.rpm rpm -ivh postfix-2.1.5-4.2.RHEL4.mysql.centos4.i386.rpm yum -y install dovecot
Ok great all the needed stuff is installed. So lets add a vmail user to the system
groupadd -g 901 vmail useradd -u 901 -g 901 vmail
Then you want to edit /etc/postfix/main.cf and add this to the bottom. Take a note of /vmail change that to the location you want to store all your email in.
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf virtual_gid_maps = static:901 virtual_mailbox_base = /vmail virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf virtual_mailbox_limit = 51200000 virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf virtual_minimum_uid = 901 virtual_transport = virtual virtual_uid_maps = static:901
ok save the file and create a new file in /etc/postfix/mysql_virtual_alias_maps.cf and add the following
user = postfix password = postfix hosts = localhost dbname = postfix table = alias select_field = goto where_field = address
ok save the file and create a new file in /etc/postfix/mysql_virtual_domains_maps.cf and add the following
user = postfix password = postfix hosts = localhost dbname = postfix table = domain select_field = domain where_field = domain #additional_conditions = and backupmx = '0' and active = '1'
ok save the file and create a new file in /etc/postfix/mysql_virtual_mailbox_maps.cf and add the following
user = postfix password = postfix hosts = localhost dbname = postfix table = mailbox select_field = maildir where_field = username #additional_conditions = and active = '1'
ok save the file and create a new file in /etc/postfix/mysql_virtual_mailbox_limit_maps.cf and add the following
user = postfix password = postfix hosts = localhost dbname = postfix table = mailbox select_field = quota where_field = username #additional_conditions = and active = '1'
ok save the file and create a new file in /etc/postfix/mysql_relay_domains_maps.cf and add the following
user = postfix password = postfix hosts = localhost dbname = postfix table = domain select_field = domain where_field = domain additional_conditions = and backupmx = '1'
now save that and lets chown them
chmod 640 /etc/postfix/mysql_* chgrp postfix /etc/postfix/mysql_*
Now lets create the /vmail dir and give it the correct permissions
mkdir /vmail chmod 771 /vmail chown vmail:vmail /vmail
now lets restart or start postfix in this case we will start it
service postfix start
If you have sendmail on the machine already a nice little rpm to download is system-switch-mail once download run the command by the same name.. select postfix and it'll be running
Now go back to the place you untared postfixadmin and point our browser to that location like
http://jyiscool.com/postfixadmin/setup.php
Make sure you pass all points.. then you want to remove the setup.php file
Ok now in the postfixadmin dir do this
cd admin
You need to setup the .htaccess file. So edit .htaccess in that dir and it will look something like this
AuthUserFile /some/dir/to/go/mail/admin/.htpasswd AuthGroupFile /dev/null AuthName "Postfix Admin" AuthType Basic <limit GET POST> require valid-user </limit>
You want to change AuthUserFile to the path where that .htpasswd file is that you just put your postfixadmin app.
Once thats installed delete the file and we will create a new one since we don't want to use the same admin user that is in there by default
rm -rf .htpasswd htpasswd -c .htpasswd username
Now edit the config.inc.php file
cd .. mv config.inc.php-dist config.inc.php
Basically you just have to change some defaults to suit your needs.. From there you should be able to access the admin error by entering the user/pass you just made and create a new domain and create some new users..
Once you have done that you should be able to use the local mail command to send off a test email to make sure its in the /vmail dir
echo testing 1 2 3 | mail -s test user@jyiscool.com
if you see a /vmail/user@jyiscool.com directory then it worked.. yayaya
Now I like setting up new services like I like my women.. easy
So create a new file called /etc/dovecot-mysql.conf with the following contents
db_host = 127.0.0.1 db_port = 3306 db = postfix db_user = postfix db_passwd = postfix db_client_flags = 0 default_pass_scheme = PLAIN password_query = SELECT password FROM mailbox WHERE username = '%u' user_query = SELECT maildir, 901 AS uid, 901 AS gid FROM mailbox WHERE username = '%u'
Save that and edit the /etc/dovecot.conf file and add the following at the bottom
auth_userdb = mysql /etc/dovecot-mysql.conf auth_passdb = mysql /etc/dovecot-mysql.conf first_valid_uid = 501 default_mail_env = maildir:/vmail/%u
i also turned off ssl.. I might enable it in the future and append to this howto.. but for now in my dovecot.conf there is ssl_disable = yes
Now start dovecot
service dovecot start
You should not be able to grab that email you just sent that user via imap/pop3
Now make sure both get loaded on boot
chkconfig dovecot on chkconfig postfix on
Now I am pretty drunk now while doing this so there could be many errors.. deal with it










