PostfixAdmin on Ubuntu 9.10
PostfixAdmin provides a way to manage your virtual accounts, multiple domains, using a web based interface. Once it is set up it is very easy to use. This install process is not easy to do as there are many commands and a lot of configuration that must be done without mistakes. If you would like a Live Virtual Class for Postfix, click on the link for more information. To get started you will need to install postfix and dovecot-postfix.
apt-get install postfix dovecot-postfix
If you install Postfix at install you can just choose this option.

When you have the options to choose what type of mail site select “Internet Site” and enter the domain you will use as the canonical or main domain. Note the canonical domain cannot be listed as a virtual domain.
The next step is to use MySQL for the virtual users and configure dovecot-postfix to connect to the MySQL database.
Install MySQL and Postfix MySQL
apt-get install mysql-server postfix-mysql
When you install MySQL it will require a password for the root user for MySQL, do not confuse this with the root user on the system…and write down the password you use…you will need it.
Now secure the user and create the database.
Start MySQL
mysql -u root -p
CREATE DATABASE postfix;
CREATE USER ‘postfix’@'localhost’ IDENTIFIED BY ‘your_password’;
GRANT ALL ON postfix.* to ‘postfix’@'localhost’;
Install PostfixAdmin
The PostfixAdmin program is a web based administration panel for Postfix. There are several advantages for this program. It is an easy interface to work with to install new domains, users and of course set up autoresponders for your users. You still have to be able to work at the command line to set up Postfix features however. You need to install PHP5 and apache2 as well and several helper programs.
sudo apt-get install apache2 php5 php5-mysql php5-imap
sudo /etc/init.d/apache2 restart
Once that is done you should be able to see the default web server page when you point your browser to the server IP Address.
Move to the /var/www directory
/var/www
Download postfixadmin
wget http://downloads.sourceforge.net/sourceforge/postfixadmin/postfixadmin_2.3rc7.tar.gz
tar -zxvf postfixadmin_2.3rc7.tar.gz
Rename the directory and remove the tarball
mv postfixadmin-2.3rc7 postfixadmin
rm postfixadmin_2.3rc7.tar.gz
Set the configuration for postfixadmin
cd postfixadmin
nano config.inc.php
$CONF['configured'] = true;
$CONF['postfix_admin_url'] = $_SERVER['HTTP_HOST'].’/postfixadmin’;
$CONF['database_password'] = ‘your_passowrd_for_the_db’;
Update the following variables to what makes sense for your installation
$CONF['admin_email']
$CONF['default_aliases']
Change tis line to “true” as seen to verify a completed configuration.
$CONF['configured'] = true;
Save
Point our browser to: http://server_ip/postfixadmin/setup.php.
You will see an overview of settings that you need to configure…fix all problems before you proceed.

Refresh the setup page each time you make a change to verify it is fixed.
At the bottom you will see that you will need to create a password.

The hashed password that is created you will need to place in the config.in.php.
nano config.inc.php
Update $CONF['setup_password']
Save
Now create a new admin with an email.

At this point you need to set up the connections to the MySQL database. To do this you need ot create 4 files so that MySQL and Postfix can communicate.
cd /etc/postfix
nano my_alias_maps.cf
user = postfix
password = db_passwd
hosts = localhost
dbname = postfix
query = SELECT goto FROM alias WHERE address = ‘%s’ AND active = 1
Save
nano my_domains_maps.cf
user = postfix
password = db_passwd
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain = ‘%s’ AND backupmx = 0 AND active = 1
Save
nano my_mailbox_limits.cf
user = postfix
password = db_passwd
hosts = localhost
dbname = postfix
query = SELECT quota FROM mailbox WHERE username = ‘%s’ AND active = 1
Save
nano my_mailbox_maps.cf
user = postfix
password = db_passwd
hosts = localhost
dbname = postfix
query = SELECT CONCAT(domain,’/',maildir) FROM mailbox WHERE username = ‘%s’ AND active = 1
Save
Edit the main.cf file.
virtual_minimum_uid = 150
virtual_uid_maps = static:150
virtual_gid_maps = static:8
virtual_mailbox_base = /var/vmail
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
virtual_alias_maps = proxy:mysql:/etc/postfix/my_alias_maps.cf
virtual_mailbox_limit = proxy:mysql:/etc/postfix/my_mailbox_limits.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/my_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/my_mailbox_maps.cf
Comment out or delete these options.
#home_mailbox = Maildir/
#mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot-postfix.conf -n -m “${EXTENSION}”
You cannot have virtual domains listed in the mydestination option.
Save
Edit the master.cf
dovecot unix – n n – - pipe flags=DRhu user=vmail:mail argv=/usr/lib/dovecot/deliver -c
/etc/dovecot/dovecot-postfix.conf -f ${sender} -d $(recipient)
Save
Create /var/mail and a user for permissions.
useradd -r -u 150 -g mail -d /var/vmail -s /sbin/nologin vmail
mkdir /var/vmail
chmod 770 /var/vmail
chown vmail:mail /var/vmail/
Finally, you have to make some changes to the dovecot configuration to accept the mail and deliver it
cd /etc/dovecot
Edit dovecot-sql.conf
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=db_password
default_pass_scheme = MD5-CRYPT
user_query = SELECT ‘/var/vmail/%d/%n’ as home, ‘maildir:/var/vmail/%d/%n’ as mail, 150 AS uid, 8 AS gid, concat(‘dirsize:storage=’, quota) AS quota FROM mailbox WHERE username = ‘%u’ AND active = 1
password_query = SELECT username as user, password, ‘/var/vmail/%d/%n’ as userdb_home, ‘maildir:/var/vmail/%d/%n’ as userdb_mail, 150 as userdb_uid, 8 as userdb_gid FROM mailbox WHERE username = ‘%u’ AND active = 1
Save
Edit dovecot-postfix.conf
Adjust several settings.
mail_location = maildir:/var/vmail/%d/%n
first_valid_uid = 150
last_valid_uid = 150
passdb sql {
args = /etc/dovecot/dovecot-sql.conf
}
userdb sql {
args = /etc/dovecot/dovecot-sql.conf
}
master {
path = /var/run/dovecot/auth-master
mode = 0660
user = vmail
group = mail
}
Save
Restart both services so changes take effect
/etc/init.d/postfix restart
/etc/init.d/dovecot restart
If you are still having problems consider the Postfix Mail Server Course.
Posted by mike 

Trackbacks
Thursday, 17 December, 2009
Social comments and analytics for this post…
This post was mentioned on Friendfeed by Andrew: Using PostfixAdmin on Ubuntu 9.10 http://bit.ly/8uaqSR...
You must be logged in to post a comment.