wiki:howto/PostfixAdmin

<- Back to the HOWTO section

Setting up postfixadmin

  • Audience: intermediate/advanced users & administrators
  • Requires: MacPorts >= 1.9.2
  • Author: Bjarne D Mathiesen - macintosh _at_ mathiesen _dot_ info
  • Date: 26/06-2011

Introduction

!!! NOTE !!!

I'm custom-installing MacPorts and everything heavily. I'm documenting my own procedures here along with musing as to why I'm doing what I'm doing. If you want to install somewhere else or in the standard paths, you'll have to modify some settings and path values to suit your own needs.

At present this is a bit raw ... I've chosen to just dump configuration settings and procedures in this howto to get it started.

During the whole process it's a very good idea to open a terminal windows to tail -40f /private/var/log/mail.log/ to see what happening with postfix. If something is wrong with postfix, this is the place to see it.

I'll also recommend that you do a tail -40f /macports/apache2/logs/error_log.

Installation

Step 1: Apache Configuration

I'm setting postfixadmin up as a subdomain : http://postfixadmin.testdomain.test/.

The procedure for setting it up as as http://www.testdomain.test/postfixadmin/ can be found in howto/MAMP

NameVirtualHost *:80

# This emty VirtualHost has the effect that Apache serves the pages defined in the main part as the default server
<VirtualHost *:80>
</VirtualHost>

#
# Here are the site specific settings for postfixadmin.mathiesen.test
# Settings not defined here will be taken over from the main server in httpd.conf
#
<VirtualHost *:80>

##
## httpd.conf -- Apache HTTP server configuration file
##

    ServerName postfixadmin.mathiesen.test

    DocumentRoot "/Volumes/Bjarne/Sites/info/mathiesen/postfixadmin/html"
    <Directory "/Volumes/Bjarne/Sites/info/mathiesen/postfixadmin/html">
        Options Indexes
        AllowOverride None

        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog "|/macports/sbin/cronolog /Volumes/Bjarne/Sites/info/mathiesen/postfixadmin/logs/error/%Y%m.log"
    LogLevel warn
    CustomLog "|/macports/sbin/cronolog /Volumes/Bjarne/Sites/info/mathiesen/postfixadmin/logs/access/%Y%m.log" common

    SetEnv WEB_SITE postfixadmin.mathiesen.test

# This is a security recommendation from the INSTALL.TXT file in postfixadmin
    SetEnv DB_USER "postadmin"
    SetEnv DB_PASS "postadmin"

##
## php.ini
##
    php_value include_path ".:/Volumes/Bjarne/Sites/info/mathiesen/postfixadmin"
    php_value open_basedir "/Volumes/Bjarne/Sites/info/mathiesen/postfixadmin/"
    php_value session.save_path "/Volumes/Bjarne/Sites/info/mathiesen/postfixadmin/php-sessions"
    php_value session.name "PHPSESSID"
    php_value session.cookie_domain "postfixadmin.mathiesen.test"

</VirtualHost>

# This VirtualHost is a catch-all that redirects <everything>.mathiesen.test to www.mathiesen.test
<VirtualHost *:80>
    ServerName mathiesen.test
    ServerAlias *.mathiesen.test

    Redirect / http://www.mathiesen.test
</VirtualHost>

To test if your setup can start without initial problems, execute

/macports/apache2/bin/httpd -S

Step 2: Postfix Configuration

You'll have to edit the main.cf file and add these settings. The settings here are based upon information in the files

  • POSTFIX_CONF from postfixadmin
  • VIRTUAL_README from postfix

I'm storing the settings and the mail way outside the system paths. It's my plan to set up a RAID 1 to hold my email folders etc. I'm already doing this for my websites.

# ADDRESS REDIRECTION (VIRTUAL DOMAIN)
#
# The VIRTUAL_README document gives information about the many forms
# of domain hosting that Postfix supports.

virtual_mailbox_base = /Volumes/Bjarne/Sites/postfix/mail
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

virtual_mailbox_domains = proxy:mysql:/Volumes/Bjarne/Sites/postfix/mysql/virtual_domains_maps.cf
virtual_alias_maps =
   proxy:mysql:/Volumes/Bjarne/Sites/postfix/mysql/virtual_alias_maps.cf,
   proxy:mysql:/Volumes/Bjarne/Sites/postfix/mysql/virtual_alias_domain_maps.cf,
   proxy:mysql:/Volumes/Bjarne/Sites/postfix/mysql/virtual_alias_domain_catchall_maps.cf
virtual_mailbox_maps =
   proxy:mysql:/Volumes/Bjarne/Sites/postfix/mysql/virtual_mailbox_maps.cf,
   proxy:mysql:/Volumes/Bjarne/Sites/postfix/mysql/virtual_alias_domain_mailbox_maps.cf

virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/Volumes/Bjarne/Sites/postfix/mysql/virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please try again later.
virtual_overquota_bounce = yes

We'll have to make sure postfix can access and write to the virtual_mailbox_base

chown _postfix:5000 /Volumes/Bjarne/Sites/postfix
chmod 0770 /Volumes/Bjarne/Sites/postfix

The *.cf files can be found as attachments to this howto. You'll have to be careful with the line endings in the files making sure they are *NIX ones (LF) and not Classic Mac [CR). This tripped me up initially, and I got at lot of error messages in private/var/log/mail.log that were at bit hard to figure out !

Step 3: MySQL Configuration part 1

see my tutorial on [wiki:howto/MySQLWorkbench MySQL Workbench

Step 4: Postfixadmin Configuration

Start by making a copy of the file config.inc.php naming it config.inc.edited.php. Then, edit the settings in the copy to your likings. Based upon the default and the edited file we'll make a config.local.php. config.local.php will hold settings that overrides the default settings from config.inc.php

cd /Volumes/Bjarne/Sites/info/mathiesen/postfixadmin/html
diff config.inc.php config.inc.edited.php | sed -En -e '/^>/p' | sed -E -e 's/^> //' > config.local.php

You'll have to add some lines manually in order for config.local.php to work properly.

<?php                                                // add this line manually
$CONF['configured'] = true;
$CONF['setup_password'] = 'md5cryptpassword';
$CONF['postfix_admin_url'] = 'http://postfixadmin.mathiesen.test';
$CONF['default_language'] = 'da';
$CONF['database_type'] = 'mysqli';
$CONF['database_user'] = $_SERVER['DB_USER'];
$CONF['database_password'] = $_SERVER['DB_PASS'];
$CONF['database_name'] = 'webmail';
$CONF['admin_email'] = 'macintosh@mathiesen.info';
$CONF['min_password_length'] = 8;
$CONF['generate_password'] = 'YES';
$CONF['show_password'] = 'YES';
$CONF['page_size'] = '20';
$CONF['default_aliases'] = array (                   // add this line manually
    'abuse'         => 'mailadmin@mathiesen.test',
    'hostmaster'    => 'mailadmin@mathiesen.test',
    'postmaster'    => 'mailadmin@mathiesen.test',
    'webmaster'     => 'mailadmin@mathiesen.test'
);                                                   // add this line manually
$CONF['domain_path'] = 'YES';
$CONF['quota'] = 'YES';
$CONF['quota_multiplier'] = '1048576';
$CONF['fetchmail'] = 'NO';
$CONF['show_header_text'] = 'YES';
$CONF['user_footer_link'] = "http://avisbude.test/";
$CONF['footer_link'] = 'http://avisbude.test/';
$CONF['create_mailbox_subdirs_prefix']='';
$CONF['new_quota_table'] = 'YES';
?>                                                   // add this line manually

Step 5: Postfixadmin First Run

Access http://postfixadmin.mathiesen.test/setup.php and create a superadmin. You'll get a password that you'll have to set as the value for $CONF['setup_password'] in config.local.php

Now, access http://postfixadmin.mathiesen.test/ and log in as your superadmin. Do the following steps :

  1. create at least one domain for which to administer email for
  2. create additional administrators if necessary
  3. create email accounts and send the welcome email to them.

Step 6: MySQL Configuration part 2

Optional Parts

TODO: What else can be done?

<- Back to the HOWTO section

Last modified 6 years ago Last modified on Jun 26, 2011, 4:56:47 PM

Attachments (7)

Download all attachments as: .zip