Richard
Note: These instructions are identical for Leopard and Snow Leopard.
Postfixadmin is a web based management tool created for Postfix based mailservers. It is a PHP based application that handles Postfix style virtual domains and users that are stored in MySQL or PostgreSQL. This will enable you to add domains and users to your mailserver without having to dive into configuration files. It will also allow you to delegate the control of a single domain to another user.
Please download the source code form the PostfixAdmin project page at sourceforge.net. These instructions have only been tested with version 2.2.x.x.
First you need to create a database, you can use a database management tool like phpMyAdmin or use the command line. For command line you can use the following commands whilst in mysql:
CREATE USER 'postfix'@'localhost' IDENTIFIED BY 'postfixpassword';
GRANT ALL PRIVILEGES ON postfix.* TO 'postfix'@'localhost';
This will have created a database named “postfix” and a user named “postfix” who can logon with password “postfixpassword”. Please do not use “postfixpassword” as the actual password and choose someting of your own.
Unpack the downloaded postfixadmin archive into the directory ‘/Library/WebServer/Documents‘, that is if you used our installation instructions. Otherwise extract it in the document root of your Apache installation.
For ease of use you can rename the directory ‘postfixadmin-2.2.x‘ to just ‘postfixadmin‘ or create a symbolic link to that directory as follows:
When you’re done you need to edit the file ‘config.inc.php‘ file.
The most important settings are those for your database server settings:
You must also change the line that says :
to
Change your URL location:
and change the database config block into:
$CONF['database_host'] = ‘localhost’;
$CONF['database_user'] = ‘postfix’;
$CONF['database_password'] = ‘postfixpassword’;
$CONF['database_name'] = ‘postfix’;
$CONF['database_prefix'] = ”;
When you finish, save the file and go to http://yourserver.tld/postfixadmin/setup.php in a web browser. The script will check your environment and you should see a list of ‘OK’ messages. The setup.php script will attempt to create the database structure.
Assuming everything is OK you can specify an email address and a make up a password and press the button. Please remember these as you will need them the following time when you want to administer your server. When the admin user is added succesfully remove the setup.php file for security by using the following command:
You can then go into ‘http://yourserver.tld/postfixadmin/‘ to administrate your users and domain admins. Log in with your newly created admin account to add users and domains.



Comments
8:39 pm
Hi Richard,
I’m getting a bit closer but got this problem now.
[Thu Aug 20 21:37:27 2009] [error] [client ::1] File does not exist: /Library/WebServer/Documents/idsmac.net/postfixadmin
The folder postfixadmin in the Documents folder but this error suggest it needs to be in website folder.
Any clue
Luc
8:24 pm
Luc, my best guess would be that you are trying to reach postfix admin through one of your virtual domains which won’t work if you put it in the Documents folder. To make this work you either need to move postfix admin into a site folder or access it via your http://hostname/postfixadmin
2:54 am
Richard,
I got a lot further now but I get this error on the postfixadmin setup:
Warning: Depends on: IMAP functions – NOT FOUND
To install IMAP support, install php5-imap
Without IMAP support, you won’t be able to create subfolders when creating mailboxes.
I don’t see in the php install tutorial where I needed to do anything with Imap. Did I miss it? Or is this warning expected and should I move on to the next step?
thanks
6:59 am
@Rodrigo, do not worry, everything will work without the imap module. It’s only required for some special stuff we aren’t using.
9:38 pm
I went ahead and follow through, however, when I input the setup password the next screen said to put the generated hash value in the config.inc.php page and it asked me to input the setup password again followed by the admin email and new admin password. When I hit submit the page turns all white.
Following the tutorial I went to myserver/postfixadmin and the form to login shows up but it keeps saying the username or password do not match.
I checked my database and the postfix user exists and has priviledges. But the admin user is never created in the admin table. Any suggestions?
Thank you
8:40 pm
I wasn’t able to setup Postfix Admin properly.
The error I received was:
Error: Can’t connect to database
Please edit the $CONF['database_*'] parameters in config.inc.php.
DEBUG INFORMATION:
Connect: Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2)
Here is my $CONF block (with substitute password, of course):
$CONF['database_type'] = ‘mysqli’;
$CONF['database_host'] = ‘localhost’;
$CONF['database_user'] = ‘postfix’;
$CONF['database_password'] = ‘mypassword’;
$CONF['database_name'] = ‘postfix’;
$CONF['database_prefix'] = ”;
2:49 pm
Looks like your mysql socket is configured wrong. To find out where your socket is located run the command “mysql_config” then edit your /etc/php.ini to change it to the correct location.
12:13 am
Hello:
I keep getting the following error when I attempt to create the user postfix per the statement in these instructions:
ERROR 1396 (HY000): Operation CREATE USER failed for ‘postfix’@'localhost’
Any ideas, please? I have tried this as a normal user and as sudo. No luck.
6:52 am
@Lewis, you need to login to mysql with the proper admin rights you configured while installing/securing MySQL. Something like: mysql -uyouradminuser -p
9:53 pm
Thank you, Richard.
I got past that obstacle successfully and went to setup.php via the browser and have run into this error:
# Error: Can’t connect to database
Please edit the $CONF['database_*'] parameters in config.inc.php.
DEBUG INFORMATION:
Invalid $CONF['database_type']! Please fix your config.inc.php!
I have tried ‘mysql’ and ‘mysqli’ for the database type and neither gets me past this error. I am using MySQL 5.x.
Any idea? I am setting this up on a Snow Leopard Server. Could that be a problem?
10:10 am
If you want to have different admins set-up for each domain and want to have one postfixadmin install across all the domains:
Create symlink at the root directory of each domain.
ln -s /www/domain1.com/postfixadmin postfixadmin
And in the config.inc.php change this line to:
$CONF['postfix_admin_url'] = $_SERVER['HTTP_HOST'].’/postfixadmin’;
10:11 am
In addition to:
mv setup.php setup.php.disabled
you’ll want to:
mv upgrade.php upgrade.php.disabled
and probably chmod 400 to both so no outsiders can read the files by accident (especially with MySQL passwords involved).
3:52 pm
Because my mysql.sock was /tmp/mysql.sock
and because postfixadmin php script doesn’t offer the possibility
to configure it from the config.inc.file,
I had to edit the functions.inc.php file and around
line 1467, set connexion params of your own, like this
$link = mysqli_connect (
$CONF['database_host'],
$CONF['database_user'],
$CONF['database_password'],
”,
3306,
‘/tmp/mysql.sock’
) or $error_text .= (“DEBUG INFORMATION:Connect: ” . mysqli_connect_error () . “$DEBUG_TEXT”);
Note, I also added this
date_default_timezone_set(‘Europe/Paris’);
as first php instruction to fix a timezone error.
@Lewis, I had the same problem,
you can see exactly what’s going on by removing the @ symbol line 1467
of the functions.inc.php
Mean
replace this
$link = @mysqli_connect ($CONF['database_host'],…
by this
$link = mysqli_connect ($CONF['database_host'], …
7:15 pm
@lingtalfi, you can set the socket in your php.ini, I will add it to the document.
7:28 pm
@Richard, yes sure (sudo pico -w +1064 /etc/php.ini), but what if another “myadmin” like has socket config somewhere else ? I personally like it in /tmp/mysql.sock as it is mysql’s default location, hence I would not permit a php programm to impose his will against mine (lol)
7:41 pm
@lingtalfi, If there is no socket definition in a php based app configuration it uses the one in php.in. So this would work for any php based application.