Home > Guides > Alpine Server > Setting up Postfixadmin

Setting up Postfixadmin

Installation

Install postfixadmin, dovecot (necessary for the SHA512-CRYPT) and the necessary PHP extensions:

apk add postfixadmin dovecot php-pgsql php-imap php-mbstring php-session

Configuration

Create the /usr/share/webapps/postfixadmin/templates_c directory:

mkdir -p /usr/share/webapps/postfixadmin/templates_c
chown www: /usr/share/webapps/postfixadmin/templates_c

Copy /usr/share/webapps/postfixadmin/config.inc.php:

cp /etc/postfixadmin/config.inc.php /usr/share/webapps/postfixadmin/config.local.php

Edit /usr/share/webapps/postfixadmin/config.local.php:

$CONF['configured'] = true;
$CONF['setup_password'] = ""; // Don't change this yet.
$CONF['database_type'] = 'pgsql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfixadmin';
$CONF['database_password'] = 'password'; // Change this to your password.
$CONF['database_name'] = 'postfix';
$CONF['database_prefix'] = "";
$CONF['admin_email'] = 'you@yourdomain.com'; // Replace with your e-mail address.
$CONF['encrypt'] = 'dovecot:SHA512-CRYPT';
$CONF['authlib_default_flavor'] = 'SHA';
$CONF['dovecotpw'] = "/usr/bin/doveadm pw";
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['aliases'] = '10';
$CONF['mailboxes'] = '10';
$CONF['maxquota'] = '10';
$CONF['quota'] = 'YES';
$CONF['quota_multiplier'] = '1024000';
$CONF['vacation'] = 'NO'; 
$CONF['vacation_control'] ='NO';
$CONF['vacation_control_admin'] = 'NO';
$CONF['alias_control'] = 'YES';
$CONF['alias_control_admin'] = 'YES';
$CONF['special_alias_control'] = 'YES';
$CONF['fetchmail'] = 'NO';
$CONF['user_footer_link'] = "http://localhost:8000/postfixadmin";
$CONF['footer_link'] = 'http://localhost:8000/postfixadmin/main.php';
$CONF['create_mailbox_subdirs_prefix']="";
$CONF['used_quotas'] = 'YES';
$CONF['new_quota_table'] = 'YES';

Replace change-this-to-your-domain.tld to your domain name:

sed -i -e 's/change-this-to-your.domain.tld/example.com/g' /usr/share/webapps/postfixadmin/config.local.php

Add the following to /etc/nginx/sites-available/02_localhost:

	location /postfixadmin {
		alias /usr/share/webapps/postfixadmin/public;
	}

	location ~ \.php$ {
		location ~ ^/postfixadmin/ {
			alias /usr/share/webapps/postfixadmin/public;
			fastcgi_split_path_info ^/postfixadmin(.+?\.php)(.*)$;
			include fastcgi.conf;
			fastcgi_pass 127.0.0.1:9000;
		}

		fastcgi_split_path_info ^(.+?\.php)(.*)$;
		include fastcgi.conf;
		fastcgi_pass 127.0.0.1:9000;
	}

Forward the port using SSH:

ssh -L 8000:localhost:8000 example.com

Point your browser to http://localhost:8000/postfixadmin/setup.php and create the password hash. Then add it to /usr/share/webapps/postfixadmin/config.local.php. Go back to http://localhost:8000/postfixadmin/setup.php and create the superadmin account.