Addition/Install.PostfixAdmin.For.MySQL.Backend
From iRedMail
(→Restart Apache web server to make it work) |
(→Add missing SQL tables in database 'vmail') |
||
| (3 intermediate revisions not shown) | |||
| Line 12: | Line 12: | ||
* There's no guarantee to keep iRedMail compatible with PostfixAdmin SQL structure in the future. | * There's no guarantee to keep iRedMail compatible with PostfixAdmin SQL structure in the future. | ||
* This tutorial is wrote for iRedMail-0.7.0, it probably need some adjustments for later versions. | * This tutorial is wrote for iRedMail-0.7.0, it probably need some adjustments for later versions. | ||
| + | |||
| + | = Add missing SQL tables in database 'vmail'= | ||
| + | |||
| + | Please add below SQL tables in database '''vmail''' for PostfixAdmin: | ||
| + | {{cmd|<pre> | ||
| + | CREATE TABLE IF NOT EXISTS log ( | ||
| + | TIMESTAMP DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| + | username VARCHAR(255) NOT NULL DEFAULT '', | ||
| + | domain VARCHAR(255) NOT NULL DEFAULT '', | ||
| + | action VARCHAR(255) NOT NULL DEFAULT '', | ||
| + | data VARCHAR(255) NOT NULL DEFAULT '', | ||
| + | KEY TIMESTAMP (TIMESTAMP) | ||
| + | ) ENGINE=MyISAM; | ||
| + | |||
| + | CREATE TABLE IF NOT EXISTS vacation ( | ||
| + | email VARCHAR(255) NOT NULL DEFAULT '', | ||
| + | subject VARCHAR(255) NOT NULL DEFAULT '', | ||
| + | body TEXT NOT NULL, | ||
| + | cache TEXT NOT NULL, | ||
| + | domain VARCHAR(255) NOT NULL DEFAULT '', | ||
| + | created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| + | modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| + | active TINYINT(4) NOT NULL DEFAULT '1', | ||
| + | PRIMARY KEY (email), | ||
| + | KEY email (email) | ||
| + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; | ||
| + | |||
| + | CREATE TABLE IF NOT EXISTS vacation_notification ( | ||
| + | on_vacation VARCHAR(255) NOT NULL, | ||
| + | notified VARCHAR(255) NOT NULL, | ||
| + | notified_at TIMESTAMP NOT NULL DEFAULT now(), | ||
| + | CONSTRAINT vacation_notification_pkey PRIMARY KEY(on_vacation, notified), | ||
| + | FOREIGN KEY (on_vacation) REFERENCES vacation(email) ON DELETE CASCADE | ||
| + | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; | ||
| + | </pre>}} | ||
=Download and uncompress PostfixAdmin = | =Download and uncompress PostfixAdmin = | ||
| Line 70: | Line 105: | ||
# echo '' > motd-users.txt | # echo '' > motd-users.txt | ||
</pre>}} | </pre>}} | ||
| + | |||
| + | PostfixAdmin will send a welcome message to newly created mail users, but it will be failed since iRedMail requires sender login. Here's a patch to disable welcome message: | ||
| + | * http://iredmail.googlecode.com/hg/tags/0.6.1/patches/postfixadmin/create_mailbox.patch | ||
= Configure PostfixAdmin = | = Configure PostfixAdmin = | ||
| Line 188: | Line 226: | ||
= Important Notes = | = Important Notes = | ||
| - | Default SQL structure in iRedMail-0.7.0 are slightly changed. In '''"vmail.mailbox"''', transport is set to '' (empty, not a SPACE character) by default, like below: | + | * Default SQL structure in iRedMail-0.7.0 are slightly changed. In '''"vmail.mailbox"''', transport is set to '' (empty, not a SPACE character) by default, like below: |
<pre> | <pre> | ||
CREATE TABLE IF NOT EXISTS mailbox ( | CREATE TABLE IF NOT EXISTS mailbox ( | ||
| Line 202: | Line 240: | ||
query = SELECT mailbox.transport FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.domain='%d' AND mailbox.domain=domain.domain AND mailbox.transport<>'' AND mailbox.active=1 AND mailbox.enabledeliver=1 AND domain.backupmx=0 AND domain.active=1 | query = SELECT mailbox.transport FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.domain='%d' AND mailbox.domain=domain.domain AND mailbox.transport<>'' AND mailbox.active=1 AND mailbox.enabledeliver=1 AND domain.backupmx=0 AND domain.active=1 | ||
</pre>}} | </pre>}} | ||
| + | |||
| + | * [http://code.google.com/p/iredmail/source/detail?r=a9393e05a12acfcc67d04a13eaacc3a5bc51a4ab iRedMail removed 3 tables: log, vacation, vacation_notification.] | ||
Current revision as of 16:42, 15 April 2012
Contents |
Summary
iRedMail doesn't ship PostfixAdmin since iRedMail-0.7.0, but the core columns in iRedMail SQL structure are almost same as PostfixAdmin, so you can install PostfixAdmin manually for MySQL backend to manage mail accounts.
References:
Note:
- There's no guarantee to keep iRedMail compatible with PostfixAdmin SQL structure in the future.
- This tutorial is wrote for iRedMail-0.7.0, it probably need some adjustments for later versions.
Add missing SQL tables in database 'vmail'
Please add below SQL tables in database vmail for PostfixAdmin:
| Terminal: |
CREATE TABLE IF NOT EXISTS log (
TIMESTAMP DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
username VARCHAR(255) NOT NULL DEFAULT '',
domain VARCHAR(255) NOT NULL DEFAULT '',
action VARCHAR(255) NOT NULL DEFAULT '',
data VARCHAR(255) NOT NULL DEFAULT '',
KEY TIMESTAMP (TIMESTAMP)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS vacation (
email VARCHAR(255) NOT NULL DEFAULT '',
subject VARCHAR(255) NOT NULL DEFAULT '',
body TEXT NOT NULL,
cache TEXT NOT NULL,
domain VARCHAR(255) NOT NULL DEFAULT '',
created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
active TINYINT(4) NOT NULL DEFAULT '1',
PRIMARY KEY (email),
KEY email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
CREATE TABLE IF NOT EXISTS vacation_notification (
on_vacation VARCHAR(255) NOT NULL,
notified VARCHAR(255) NOT NULL,
notified_at TIMESTAMP NOT NULL DEFAULT now(),
CONSTRAINT vacation_notification_pkey PRIMARY KEY(on_vacation, notified),
FOREIGN KEY (on_vacation) REFERENCES vacation(email) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
|
Download and uncompress PostfixAdmin
- You can download PostfixAdmin from official site here: http://sourceforge.net/projects/postfixadmin/files/ , we use PostfixAdmin-2.3.2 for example: postfixadmin-2.3.2.tar.gz, and we assume you already download it under /root/ directory.
- Uncompress PostfixAdmin to Apache server root and set correct file permission:
| Terminal: |
# # ---- On RHEL/CentOS ---- # # tar zxf /root/postfixadmin-2.3.2.tar.gz -C /var/www/ # <- Uncomress source tarball. # cd /var/www/ # ln -s postfixadmin-2.3.2 postfixadmin # <- Create a symbol link. # chown -R root:root postfixadmin # <- Set correct owner and permission. # chmod -R 755 postfixadmin # cd postfixadmin # mv setup.php setup.php.save # echo '' > motd.txt # echo '' > motd-users.txt # # ---- On Debian/Ubuntu ---- # # tar zxf /root/postfixadmin-2.3.2.tar.gz -C /usr/share/apache2/ # <- Uncomress source tarball. # cd /usr/share/apache2/ # ln -s postfixadmin-2.3.2 postfixadmin # <- Create a symbol link. # chown -R root:root postfixadmin # <- Set correct owner and permission. # chmod -R 755 postfixadmin # cd postfixadmin # mv setup.php setup.php.save # echo '' > motd.txt # echo '' > motd-users.txt # # ---- On OpenSuSE ---- # # tar zxf /root/postfixadmin-2.3.2.tar.gz -C /srv/www/ # <- Uncomress source tarball. # cd /srv/www/ # ln -s postfixadmin-2.3.2 postfixadmin # <- Create a symbol link. # chown -R root:root postfixadmin # <- Set correct owner and permission. # chmod -R 0755 postfixadmin # cd postfixadmin # mv setup.php setup.php.save # echo '' > motd.txt # echo '' > motd-users.txt # # ---- On FreeBSD ---- # # tar zxf /root/postfixadmin-2.3.2.tar.gz -C /usr/local/www/ # <- Uncomress source tarball. # cd /usr/local/www/ # ln -s postfixadmin-2.3.2 postfixadmin # <- Create a symbol link. # chown -R root:wheel postfixadmin # <- Set correct owner and permission. # chmod -R 0755 postfixadmin # cd postfixadmin # mv setup.php setup.php.save # echo '' > motd.txt # echo '' > motd-users.txt |
PostfixAdmin will send a welcome message to newly created mail users, but it will be failed since iRedMail requires sender login. Here's a patch to disable welcome message:
Configure PostfixAdmin
PostfixAdmin will read custom settings from config file "config.local.php" by default, it's great for upgrading in the futher. So we will create it under postfixadmin directory.
NOTE::
- You can find password of MySQL user "vmailadmin" in iRedMail installation directory, e.g. /root/iRedMail-0.7.0/iRedMail.tips.
- If you choose to install iRedAdmin open source edition during iRedMail installation, you can find password of MySQL user "vmailadmin" in iRedAdmin config file:
- on RHEL/CentOS: /var/www/iredadmin/ssettings.ini
- on Debian/Ubuntu: /usr/share/apache2/iredadmin/settings.ini
- on openSUSE: /srv/www/iredadmin/settings.ini
- on FreeBSD: /usr/local/www/iredadmin/settings.ini
| File: config.local.php |
<?php
// Basic configuration.
$CONF['configured'] = true;
$CONF['postfix_admin_url'] = "/postfixadmin";
$CONF['default_language'] = "en";
$CONF['database_type'] = "mysqli";
$CONF['database_host'] = "localhost";
$CONF['database_user'] = "vmailadmin";
$CONF['database_password'] = "SoElbUfarkAAzYXQVHNbNkaE9h5oY4"; # <- REPLACE THIS PASSWORD.
$CONF['database_name'] = "vmail";
$CONF['smtp_server'] = "127.0.0.1";
$CONF['domain_path'] = "YES";
$CONF['domain_in_mailbox'] = "NO";
$CONF['quota'] = "YES";
$CONF['quota_multiplier'] = 1;
$CONF['transport'] = "YES";
$CONF['transport_options'] = array ('dovecot', 'virtual', 'local', 'relay');
$CONF['transport_default'] = "dovecot";
// Enable alias domain.
$CONF['alias_domain'] = 'YES';
// Disable features we don't have.
$CONF['backup'] = "NO";
$CONF['fetchmail'] = "NO";
$CONF['sendmail'] = "NO";
$CONF['show_footer_text'] = "NO";
$CONF['emailcheck_resolve_domain'] = "NO";
// Disable PostfixAdmin style vacation. We use managesieve service instead.
$CONF['vacation_control'] = "NO";
$CONF['vacation_control_admin'] = "NO";
$CONF['admin_email'] = "www@example.com";
?>
|
Configure Apache web server
We need to make PostfixAdmin accessable in your web browser. For security reason, we enable HTTPS only for PostfixAdmin.
- On RHEL/CentOS, we need to create a new file: "/etc/httpd/conf.d/postfixadmin.conf", and modify "/etc/httpd/conf.d/ssl.conf" (Add one line):
| File: /etc/httpd/conf.d/postfixadmin.conf |
<Directory "/var/www/postfixadmin/">
Options -Indexes
</Directory>
|
| File: /etc/httpd/conf.d/ssl.conf |
# Add below lines before </VirtualHost> Alias /postfixadmin "/var/www/postfixadmin/" |
- On Debian/Ubuntu, we need to create a new file "/etc/apache2/conf.d/postfixadmin.conf", and modify "/etc/apache2/sites-enabled/default-ssl" (Add one line):
| File: /etc/apache2/conf.d/postfixadmin.conf |
<Directory "/usr/share/apache2/postfixadmin/">
Options -Indexes
</Directory>
|
| File: /etc/apache2/sites-enabled/default-ssl |
# Add below lines before </VirtualHost> Alias /postfixadmin "/usr/share/apache2/postfixadmin/" |
- On openSUSE, we need to create a new file "/etc/apache2/conf.d/postfixadmin.conf", and modify "/etc/apache2/vhosts.d/vhost-ssl.conf" (Add one line):
| File: /etc/apache2/conf.d/postfixadmin.conf |
<Directory "/srv/www/postfixadmin/">
Options -Indexes
</Directory>
|
| File: /etc/apache2/vhosts.d/vhost-ssl.conf |
# Add below lines before </VirtualHost> Alias /postfixadmin "/srv/www/postfixadmin/" |
- On FreeBSD, we need to create a new file "/usr/local/etc/apache22/Includes/postfixadmin.conf", and modify "/usr/local/etc/apache22/Includes/extra/httpd-ssl.conf" (Add one line):
| File: /usr/local/etc/apache22/Includes/postfixadmin.conf |
<Directory "/usr/local/www/postfixadmin/">
Options -Indexes
</Directory>
|
| File: /usr/local/etc/apache22/Includes/extra/httpd-ssl.conf |
# Add below lines before </VirtualHost> Alias /postfixadmin "/usr/local/www/postfixadmin/" |
Restart Apache web server to make it work
- On RHEL/CentOS:
| Terminal: |
# /etc/init.d/httpd restart |
- On Debian/Ubuntu/openSUSE:
| Terminal: |
# /etc/init.d/apache2 restart |
- On FreeBSD:
| Terminal: |
# /usr/local/etc/rc.d/apache22 restart |
Now you can access PostfixAdmin in web browser with URL: httpS://your_server_hostname_or_IP/postfixadmin/
Important Notes
- Default SQL structure in iRedMail-0.7.0 are slightly changed. In "vmail.mailbox", transport is set to (empty, not a SPACE character) by default, like below:
CREATE TABLE IF NOT EXISTS mailbox (
[...]
transport VARCHAR(255) NOT NULL DEFAULT '',
[...]
You can simply change postfix lookup file "/etc/postfix/mysql/transport_maps_user.cf", append "AND transport<>" in "query" setting.
In iRedMail-0.7.0, it's set to:
| File: /etc/postfix/mysql/transport_maps_user.cf |
query = SELECT mailbox.transport FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.domain='%d' AND mailbox.domain=domain.domain AND mailbox.transport<>'' AND mailbox.active=1 AND mailbox.enabledeliver=1 AND domain.backupmx=0 AND domain.active=1 |
