BSD Stuff
Postfix, Courier-IMAP, MySQL, SASL2 and PostfixAdmin
12 September 2006, 09:33
I made this howto so that when and if I have to set up another Email server I can follow some basic steps. This howto is made for FreeBSD systems but can easily be ported to any Unix type Operating Systems.
The idea behind this setup was to use Postfix, Courier-IMAP and MySQL with PostfixAdmin to administrate the email accounts on my server. I’m also using a virtual mail setup because I don’t feel there’s a need to create a users account for every email account I add. Of course when the user wants to use an email client like Mozilla Thunderbird then I have to create an user account other wise the client will not be able to send emails because it can’t authenticate.
I just want to thank the two poeple who created there own howtos which I used to make my own.
- Postfix+MySQL+Courier-IMAP by Phil Pereira and
- Postfix+MySQL+Courier-IMAP by Mischa Peters
So lets start
I will assume that we already have Apache, PHP MySQL installed and working.
Also make sure that your ports tree is up to date.
Installing PostfixAdmin
We will use PostfixAdmin to administrate our mail server. So we will install it first.
# cd /usr/ports/mail/postfixadmin/# make install clean
Now we need to add the alias directory under apache.
# cd /usr/local/etc/apache22/extra/# vim httpd-autoindex.conf
| # | Code |
|---|---|
| 0001 | Alias /postfixadmin "/usr/local/www/postfixadmin/" |
| 0002 | |
| 0003 | <Directory "/usr/local/www/postfixadmin"> |
| 0004 | Options Indexes |
| 0005 | AllowOverride AuthConfig |
| 0006 | Allow from all |
| 0007 | </Directory> |
Next we need to edit the config.inc.php file and change the following.
# cd /usr/local/www/postfixadmin/# vim config.inc.php
| # | Code |
|---|---|
| 0001 | // Postfix Admin Path |
| 0002 | // Set the location to your Postfix Admin installation here. |
| 0003 | $CONF['postfix_admin_url'] = 'http://www.example.com/postfixadmin/admin'; |
| 0004 | $CONF['postfix_admin_path'] = '/postfixadmin/admin'; |
| 0005 | |
| 0006 | // Database Config |
| 0007 | // mysql = MySQL 3.23 and 4.0 |
| 0008 | // mysqli = MySQL 4.1 |
| 0009 | // pgsql = PostgreSQL |
| 0010 | $CONF['database_type'] = 'mysqli'; |
| 0011 | $CONF['database_host'] = 'localhost'; |
| 0012 | $CONF['database_user'] = 'dbuser'; |
| 0013 | $CONF['database_password'] = 'passwd'; |
| 0014 | $CONF['database_name'] = 'postfix'; |
| 0015 | $CONF['database_prefix'] = ''; |
| 0016 | |
| 0017 | // Site Admin |
| 0018 | // Define the Site Admins email address below. |
| 0019 | // This will be used to send emails from to create mailboxes. |
| 0020 | $CONF['admin_email'] = 'postmaster@'; |
| 0021 | |
| 0022 | // Default Aliases |
| 0023 | // The default aliases that need to be created for all domains. |
| 0024 | $CONF['default_aliases'] = array ( |
| 0025 | 'abuse' => 'abuse@example.com', |
| 0026 | 'hostmaster' => 'hostmaster@example.com', |
| 0027 | 'postmaster' => 'postmaster@example.com', |
| 0028 | 'webmaster' => 'webmaster@example.com' |
| 0029 | ); |
| 0030 | |
| 0031 | // Default Domain Values |
| 0032 | // Specify your default values below. Quota in MB. |
| 0033 | $CONF['aliases'] = '100'; |
| 0034 | $CONF['mailboxes'] = '100'; |
| 0035 | $CONF['maxquota'] = '100'; |
| 0036 | |
| 0037 | // Footer |
| 0038 | // Below information will be on all pages. |
| 0039 | // If you don't want the footer information to appear set this to 'NO'. |
| 0040 | $CONF['show_footer_text'] = 'YES'; |
| 0041 | $CONF['footer_text'] = 'Return to example.com'; |
| 0042 | $CONF['footer_link'] = 'http://www.example.com'; |
Now we will add the database to MySQL and edit the DATABASE_MYSQL.TXT
# vim DATABASE_MYSQL.TXT
| # | Code |
|---|---|
| 0001 | # Postfix user & password |
| 0002 | INSERT INTO user (Host, User, Password) VALUES ('localhost','dbuser',password('passwd')); |
| 0003 | INSERT INTO db (Host, Db, User, Select_priv) VALUES ('localhost','postfix','dbuser','Y'); |
| 0004 | |
| 0005 | # Postfix Admin user & password |
| 0006 | INSERT INTO user (Host, User, Password) VALUES ('localhost','dbuseradmin',password('passwd')); |
| 0007 | INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('localhost', 'postfix', 'dbuseradmin', 'Y', 'Y', 'Y', 'Y'); |
| 0008 | FLUSH PRIVILEGES; |
| 0009 | GRANT USAGE ON postfix.* TO dbuser@localhost; |
| 0010 | GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO dbuser@localhost; |
| 0011 | GRANT USAGE ON postfix.* TO dbuseradmin@localhost; |
| 0012 | GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO dbuseradmin@localhost; |
Do not delete the setup.php file yet we will need to add the domains and mail boxes first.
Now we can create the database from the shell with the following command.
# mysql -u root -p < DATABASE_MYSQL.TXTEnter password:
Now that we installed PostfixAdmin we can go and install Postfix.
Page 1 of 6