Postfix it’s a great mailserver, but it’s not the easiest of the beast to tame if you aren’t an expert system administrator and just want to setup a mail service for your server and domain, so today I’ll show you how to install and configure PostfixAdmin a web based interface used to manage mailboxes, virtual domains and aliases. It also features support for vacation/out-of-the-office messages.
This software is compatible with different databases and IMAP/POP3 server, in the following article I’ll use Mysql as database server, on a Centos 6 Linux server.
Short Description and features:
Postfix Admin is a Web Based Management tool created for Postfix. It is a PHP based application that handles Postfix Style Virtual Domains and Users that are stored in MySQL or PostgreSQL.
- Web based administration for a virtual Postfix mail server
- MySQL or PostgreSQL database support
- Fetchmail support
- Vacation / auto-reply support
- Squirrelmail / Roundcube integration
First Step: Requirements
To run properly Postfix Admin need the following software available on your Linux server:
- Postfix 2.0 or higher.
- Apache 1.3.27 / Lighttpd 1.3.15 or higher.
- PHP 5.1.2 or higher with modules for mysql.
- MySQL (5.x recommended)
All these software are easily installable on Centos 6 via
Second Step : Postfix Admin Installation and setup
Download the latest versione of postfix Admin from sourceforge, in this moment the latest version it’s the 2.3.6.
Once downloaded the source package unpackage it on the document root of your Web Server, in this example my document root is /srv/posyfixadmin
cd /srv tar -zxvf /tmp/postfixadmin-2.3.6.tar.gz mv postfixadmin-2.3.6 postfixadmin
Setup a Database
With your chosen/preferred database server, you need to create a new database. A good name for this could be :
Most users will find using phpMyAdmin the easiest route to create a new database and user, or you can create MySQL user and databases quickly and easily by running mysql from the shell.
The syntax is shown below and the dollar sign is the command prompt:
$ mysql -uroot -p Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 5.1.67 Source distribution Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> CREATE DATABASE postfix; Query OK, 1 row affected (0.00 sec) mysql> CREATE USER 'postfix'@'localhost' IDENTIFIED BY 'yourpassword'; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL PRIVILEGES ON `postfix`.* TO 'postfix'@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye $
Now edit the config.inc.php file – or – create config.local.php and add your settings there.
The most important settings are those for your database server that should be similar to this one:
$CONF['database_type'] = 'mysql'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfix'; $CONF['database_password'] = 'yourpassword'; $CONF['database_name'] = 'postfix';
You must also change the line that says :
$CONF['configured'] = false;
$CONF['configured'] = true;
PostfixAdmin does not require write access to any files. You can therefore leave the files owned as root (or a.n.other user); as long as the web server user (e.g. www-data or apache) can read them, it will be fine.
Now open your browser at the url: http://yourservername.com/setup.php you should see a page like this one:
It will make a basic checkup of your setup and will indicates if something is missing, at my first run I was missing php-mbstring and php-imap so I installed them with:
yum install php-mbstring php-imap
And restarted Apache, reloading the page I got an “Ok”
The setup.php script will attempt to create the database structure and you can specify a password (which you’ll need to use setup.php again in the future); when you submit the form, the hashed value, which you need to enter into config.inc.php is show with these instructions:
if you want to use the password you entered as setup password, edit config.inc.php and set $CONF['setup_password'] = '1a05f571012e9f14c0f80f764d516f80:ec41add25de301101bac12649f929bbcbea8575e';
So change that line in the configuration file.
Now you can also create the postfixadmin administrator account with a form like this one:
And this end, you have successfully installed and configured Postfix Admin, you can visit your website and login with your admin account.
This is the minimum configuration to get postfix working and good for testing. It will allow you to send unsecure email on port 25. Note, it is avisable to secure your email connection to at least protect your password which is discussed below, but first make sure your basic configuration is working.
Append this to /etc/postfix/main.cf:
virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 virtual_mailbox_base = /home/vmail virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_mailbox_domains.cf virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf relay_domains = mysql:/etc/postfix/mysql_relay_domains.cf smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauth_destination, reject_unauth_pipelining, reject_invalid_hostname smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous
Create the following files with the content:
hosts = 127.0.0.1 user = postfix password = my_passwd _2 #replace with the password you set above dbname = postfixadmin query = SELECT domain FROM domain WHERE domain='%s' and backupmx = 0 and active = 1
hosts = 127.0.0.1 user = postfix password = my_passwd_2 #replace with the password you set above dbname = postfixadmin query = SELECT maildir FROM mailbox WHERE username='%s' AND active = 1
hosts = 127.0.0.1 user = postfix password = my_passwd _2 #replace with the password you set above dbname = postfixadmin query = SELECT goto FROM alias WHERE address='%s' AND active = 1
hosts = 127.0.0.1 user = postfix password = my_passwd _2 #replace with the password you set above dbname = postfixadmin query = SELECT domain FROM domain WHERE domain='%s' and backupmx = 1
pwcheck_method: saslauthd mech_list: PLAIN LOGIN auxprop_plugin: rimap
Update /etc/default/saslauthd with:
START=yes MECHANISMS="rimap" #imap server address MECH_OPTIONS="localhost" OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"
Add postfix user to sasl group:
sudo adduser postfix sasl
And now you’ll be able to create a new domain and mailboxes in it from the web with some simple forms:
- Linux Terminal: inxi – a full featured system information script
- Introduction to 4 Open Source CMS
- How to Enable your Debian Squeeze LTS security support !
- Contest for Zorin OS lovers
- Small reminder: Remember to remove all your data from Ubuntuone
Find me on Google+