To upgrade to the new postfixadmin version you’ll need to first download the source code from the Postfix Admin site.

Make a note of the settings in your current 2.1.0 installation in the ‘config.inc.php‘ file, most importantly the username and password you are using for the postfix database in case you forgot. I will guide you through the other settings.

Please make a backup of your postfix database as it will be changed during the upgrade process and you might need it to be able to roll back to the previous version if something goes wrong.

Extract the archive in your webserver directory, in our case that should be ‘/Library/WebServer/Documents/’. Edit the ‘config.inc.php‘ and change the following settings:

// comment out the following line or it won’t function
#$CONF['configured'] = false;
 
// the location of the files:
$CONF['postfix_admin_url'] = ‘http://richard5.macminicolo.net/postfixadmin’;
 
// how to connect to the database
$CONF['database_type'] = ‘mysqli’;
$CONF['database_host'] = ‘localhost’;
$CONF['database_user'] = ‘postfixadmin’;
$CONF['database_password'] = ‘postfixadminpassword’;
$CONF['database_name'] = ‘postfix’;
$CONF['database_prefix'] = ”;
 
// your administrator e-mail address
$CONF['admin_email'] = ‘postmaster@yourmaindomain.tld’;
 
// The default aliases that need to be created for all domains.
$CONF['default_aliases'] = array (
‘abuse’ => ‘abuse@yourmaindomain.tld’,
‘hostmaster’ => ‘hostmaster@yourmaindomain.tld’,
‘postmaster’ => ‘postmaster@yourmaindomain.tld’,
‘webmaster’ => ‘webmaster@yourmaindomain.tld’
);
 
// to get a mailbox structure like /domain/user
$CONF['domain_path'] = ‘YES’;
$CONF['domain_in_mailbox'] = ‘NO’;

Don’t copy the original config file as it some of the configuration parameters have changed.

Your webserver directory has now the following directories and links:

lrwxr-xr-x 1 root admin 47 Apr 25 06:43 postfixadmin ->
      /Library/WebServer/Documents/postfixadmin-2.1.0
drwxr-xr-x 44 _www _www 1496 Apr 25 12:21 postfixadmin-2.1.0
drwxr-xr-x 51 root admin 1734 May 11 11:08 postfixadmin-2.2.0

To change the link to the new version execute the following commands:

sudo rm postfixadmin
sudo ln -s /Library/WebServer/Documents/postfixadmin-2.2.0 /Library/WebServer/Documents/postfixadmin

The last thing to do is to allow the postfixadmin database to change the database for you. So login to to mysql as the root user and execute the following command:

GRANT ALL PRIVILEGES ON postfix.* TO postfixadmin@localhost;

When your done and feel comfortable to really start it up point your browser to http://yourdomain.tld/postfixadmin/upgrade.php, this will run a script which will check everything before changing the database. When everything went allright you need to create a super admin. The setup has changed and there is no longer an admin subdirectory from which you could rule them all.

If that worked please remove or move the setup file so no one else could change your configuration by accident or on purpose:

sudo mv setup.php setup.php.org

To solve the issue with the the still to fast sending of SMTP commands which will be rejected by our mailserver as it looks a lot like a spammer, it will generate the following error in your ‘var/log/mail.log‘ file:

BD5DAF029E: reject: DATA from localhost[127.0.0.1]: 503 5.5.0 : Data command rejected: Improper use of SMTP command pipelining; from= to= proto=ESMTP helo=

To get this working properly you’ll need to edit the ‘functions.inc.php‘ file, we need to add some sleep command to slow down the communication with the mailserver. Open the file and find the function ‘smtp_mail‘. Change the following code:

fputs ($fh, “EHLO $smtp_server\r\n”);
$res = smtp_get_response($fh);
fputs ($fh, “MAIL FROM:<$from>\r\n”);
$res = smtp_get_response($fh);
fputs ($fh, “RCPT TO:<$to>\r\n”);
$res = smtp_get_response($fh);
fputs ($fh, “DATA\r\n”);
$res = smtp_get_response($fh);
fputs ($fh, “$data\r\n.\r\n”);
$res = smtp_get_response($fh);
fputs ($fh, “QUIT\r\n”);
$res = smtp_get_response($fh);
fclose ($fh);

into

fputs ($fh, “EHLO $smtp_server\r\n”);
$res = smtp_get_response($fh);
usleep(10000);
fputs ($fh, “MAIL FROM:<$from>\r\n”);
$res = smtp_get_response($fh);
usleep(10000);
fputs ($fh, “RCPT TO:<$to>\r\n”);
$res = smtp_get_response($fh);
usleep(10000);
fputs ($fh, “DATA\r\n”);
$res = smtp_get_response($fh);
usleep(10000);
fputs ($fh, “$data\r\n.\r\n”);
$res = smtp_get_response($fh);
usleep(10000);
fputs ($fh, “QUIT\r\n”);
$res = smtp_get_response($fh);
fclose ($fh);

To check if everything went allright login to postfixadmin with the super admin account you created, point your browser to: http://yourdomain.tld/postfixadmin. Try to create a mailbox and check in your logfile if everything went according to plan.

If something went wrong and you want to use the previous version, restore the backup of your database and change the link to your previous version by using the following commands:

sudo rm postfixadmin
sudo ln -s /Library/WebServer/Documents/postfixadmin-2.1.0 /Library/WebServer/Documents/postfixadmin