Basic Mail Setup
Enhanced Mail Services
Wrapping it Up
Postfixadmin - A web administration frontend for postfix
With the Postgres and Postfix now running and connected, it is time to start bringing in the heavier stuff. The next step is going to require we get a web server and PHP running so that we can install our web-based admin component. I know that webmin was technically the first, but it comes all bundled up with it’s own little server so it really doesn’t count. There are plenty of guides out there about how to set up apache with php and numerous posts on http://forums.gentoo.org detailing how to solve problems with the installation (search for 'apache php'). So, that said, I'm not going to cover it here. Set up the apache and php installs and then continue with this howto.
I have included this for the sake of completeness, but have personally decided that I will not be using this package. This is not a comment about the quality of the package, it appears to be quite good, it is just that it does not manage things they way I would (how it sets up mailboxes, etc.) so I will be working directly with the database until I can provide a different front-end. That aside, the database design presented in this document is based on the postfixadmin schema so it is compatible with that application. You can go ahead and use it. UPD from Ivan: If you use PostgreSQL, PHP MUST be compiled with postgres flag! There is an ebuild available in the portage tree but it does not include postgres support. An extended ebuild that includes the necessary patches for postgres is provided via the webapps overlay. Follow the instruction provided there in order to integrate the overlay into your system and you should be able to emerge postfixadmin using the following commands afterwards:
|Shell: Emerging Postfixadmin|
# emerge -av app-portage/layman # echo "source /usr/portage/local/layman/make.conf">>/etc/make.conf # layman -S && layman -a webapps-experimental # echo "www-apps/postfixadmin" >> /etc/portage/package.keywords # echo "www-apps/postfixadmin postgres" >> /etc/portage/package.use # emerge -av postfixadmin
In case this does not work or you like to manually control your web applications, you can alternatively use the following instructions to get postfixadmin installed:
|Shell: Installing Postfixadmin|
# cd /var/www/localhost/htdocs # lynx http://high5.net/postfixadmin/download.php?file=postfixadmin-2.1.0.tgz . . . follow the lynx commands to download # tar xzpvf postfixadmin-2.1.0.tgz
You should now have a postfixadmin-2.1.0 directory in your htdocs directory. I copied it back to my ./htdocs directory for ease of access (so I could access it with a simple URL).
There is also a patch for postfixadmin that makes some minor adjustments required for use with Postgres and gives a few bonus enhancements to boot. I decided to go for it and also downloaded that to my htdocs directory and applied it the current files. Listing 7.4: Getting the Patch
|Shell: Postfixadmin Patch|
# lynx http://troels.arvin.dk/db/postfixadmin/ or # wget http://troels.arvin.dk/db/postfixadmin/postfixadmin-2.1.0-arvin-martin.patch
Once on the website, highlight the link for the patch and press “d” to download it. Save this in your /htdocs directory so you can apply it.
|Shell: Patching Postfixadmin|
# patch -p1 -d postfixadmin-2.1.0/ < postfixadmin-arvin.patch
Now we needed to copy config.inc.php.sample to config.inc.php, and adjust the config.inc.php file for the specifics of our installation. After coping the config file (in whatever directory you have selected as your web server root) open it and look for the block shown below. Adjust as required
// Database Config // mysql = MySQL 3.23 and 4.0 // mysqli = MySQL 4.1 // pgsql = PostgreSQL $CONF['database_type'] = 'pgsql'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfixadmin'; $CONF['database_password'] = '$password'; $CONF['database_name'] = 'postfix'; $CONF['database_prefix'] = '';
Finally, I had to go adjust the .htaccess file to ensure it pointed to the correct .htpasswd file (AuthUserFile).
# cd admin # nano .htaccess AuthUserFile /var/www/localhost/htdocs/admin/.htpasswd AuthGroupFile /dev/null AuthName "Postfix Admin" AuthType Basic <limit GET POST> require valid-user </limit>
When you first start, the default userid/password are admin/admin so you may want to change them as just about everybody in the world will give this one a try. Use the htpasswd2 utility provided with Apache.
|Shell: Setting .htpasswd|
# htpasswd2 .htpasswd admin New password:
Enter your new password as prompted and you are good to go. All you need to do is point your browser at your web server (http://www.example.com or http://localhost/). This will take you to the intro page and then the setup page. Be sure to read the directions provided.
I am not going to take it any further past this. I will leave it up to you to figure out if this package does what you need and verify that everything works. I did get my copy working quite well. Again, if you run into trouble, there is lots of help out there on the web.
[We need someone to finish this out. I have Postfixadmin installed, and I can add a user, however, it leaves the "email" and "homedir" fields empty in the mailbox table, plus it puts the UID/GID at 1000 automatically, with seemingly nowhere to set the defaults. I'm sure I'm not the only one.]
The default UID/GID are set while creating the table schema in the postgresql section. To change UID/GID after the tables have been created - you have to alter the UID/GID in the mailbox table, the default values are 1000.
I think I found a solution to this: using the UID and GID given to the 'vmail' user earlier, do the following (replacing $UID and $GID, of course):
|Shell: Fixing UID/GID problem|
# psql -U postgres postfix postfix=# alter table mailbox alter uid set default $UID; ALTER TABLE postfix=# alter table mailbox alter gid set default $GID; ALTER TABLE postfix=# \q
|Shell: Fixing homedir problem|
# psql -U postgres postfix postfix=# alter table mailbox alter homedir set default '/home/vmail'; ALTER TABLE postfix=# \q
I have a solution to the email field not being populated. This is going to version specific and may change over time. This was done on version 2.2 with the patching suggested earlier in the article (postfixadmin-2.1.0-arvin-martin.patch). USE AT YOUR OWN RISK! It worked fine for me with the other fixes to make postfixadmin work correctly. If you are on a different version try searching for the word INSERT, this should be the only line the includes "INTO $table_mailbox".
|Shell: Fixing blank email problem|
On line 339 of create-mailbox.php: $result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$quota','$fDomain',NOW(),NOW(),'$sqlActive')"); Change to: $result = db_query ("INSERT INTO $table_mailbox (email,username,password,name,maildir,quota,domain,created,modified,active) VALUES ('$fUsername','$fUsername','$password','$fName','$maildir','$quota','$fDomain',NOW(),NOW(),'$sqlActive')");
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.