Upgrade/iRedMail/0.6.1-0.7.0

From iRedMail

(Difference between revisions)
Jump to: navigation, search
(Check domain status in virtual_mailbox_maps, virtual_alias_maps)
(Check domain status in virtual_mailbox_maps, virtual_alias_maps)
Line 81: Line 81:
It will now check domain status, so if this domain is disabled, all users and aliases will be disabled too.
It will now check domain status, so if this domain is disabled, all users and aliases will be disabled too.
 +
 +
== Make catch-all account work as expected ==
 +
 +
To make catch-all account work as expected, we need two more SQL lookup files:
 +
* '''/etc/postfix/catchall_maps.cf''': Catch-all support for exist domains.
 +
* /etc/postfix/domain_alias_catchall_maps.cf: Catch-all support for alias domains.
 +
 +
Now edit postfix config file '''/etc/postfix/main.cf''' (Linux) or '''/usr/local/etc/postfix/main.cf''' (FreeBSD), append these two lookup files in '''virtual_alias_maps''' setting:
 +
{{cfg|main.cf|<pre>
 +
virtual_alias_maps =
 +
    proxy:mysql:/etc/postfix/mysql/virtual_alias_maps.cf,
 +
    proxy:mysql:/etc/postfix/mysql/domain_alias_maps.cf,
 +
    proxy:mysql:/etc/postfix/catchall_maps.cf,                      # <- Add this line
 +
    proxy:mysql:/etc/postfix/domain_alias_catchall_maps.cf        # <- Add this line.
 +
</pre>}}
 +
 +
Now create these two new files:
 +
 +
* /etc/postfix/catchall_maps.cf:
 +
{{cfg|catchall_maps.cf|<pre>
 +
user        = vmail
 +
password    = PASSWORD_OF_VMAIL
 +
hosts      = 127.0.0.1
 +
port        = 3306
 +
dbname      = vmail
 +
query      = SELECT alias.goto FROM alias,domain WHERE alias.address='%d' AND alias.address=domain.domain AND alias.active=1 AND domain.active=1 AND domain.backupmx=0
 +
</pre>}}
 +
 +
* /etc/postfix/domain_alias_catchall_maps.cf
 +
{{cfg|domain_alias_catchall_maps.cf|<pre>
 +
user        = vmail
 +
password    = PASSWORD_OF_VMAIL
 +
hosts      = 127.0.0.1
 +
port        = 3306
 +
dbname      = vmail
 +
query      = SELECT alias.goto FROM alias,alias_domain,domain WHERE alias_domain.alias_domain='%d' AND alias.address=alias_domain.target_domain AND alias_domain.target_domain=domain.domain AND alias.active=1 AND alias_domain.active=1
 +
</pre>}}
 +
 +
Restart postfix to make it work.
== Update SQL structure of '''vmail''' database ==
== Update SQL structure of '''vmail''' database ==

Revision as of 14:42, 18 March 2011

Contents




To be continued, do NOT apply below steps.


General Update, all backends should apply these changes

OpenLDAP backend only

Support alias domain in mail list/alias

  • Edit /etc/postfix/ldap_virtual_group_maps.cf, remove "domainName=%d" in search_base:
File: /etc/postfix/ldap_virtual_group_maps.cf
# OLD SETTING
search_base     = domainName=%d,o=domains,dc=XXX

# NEW SETTING
search_base     = o=domains,dc=XXX
  • Edit /etc/postfix/ldap_catchall_maps.cf, set query_filter to:
File: /etc/postfix/ldap_catchall_maps.cf
# NEW SETTING
query_filter     = (&(objectClass=mailUser)(accountStatus=active)(|(mail=@%d)(shadowAddress=@%d)))

Add missing value for mail users

iRedMail-0.7.0 requires enabledService=smtpsecured for sending mail via SMTP over SSL in Postfix. so we should add it if users doesn't have it.

Steps:

  • Download python script used to adding missing values.
Terminal:
# cd /root/
# wget http://iredmail.googlecode.com/hg/extra/update/updateLDAPValues_061_to_070.py
  • Open updateLDAPValues_061_to_070.py, config below parameters in file head:
File: updateLDAPValues_061_to_070.py
uri = 'ldap://127.0.0.1:389'
basedn = 'o=domains,dc=iredmail,dc=org'
bind_dn = 'cn=vmailadmin,dc=iredmail,dc=org'
bind_pw = 'passwd'

Tip:

    • You can find them in iRedAdmin config file or iRedMail.tips file under your iRedMail installation directory.
    • Use 'cn=Manager' instead of 'cn=vmailadmin' here is ok too.
  • Execute this script, it will add missing values for mail accounts:
Terminal:
# python updateLDAPValues_061_to_070.py

MySQL backend only

Improve backup mx support

  • Edit /etc/postfix/mysql_domain_alias_maps.cf, change query = to below new setting:
File: /etc/postfix/mysql_domain_alias_maps.cf
query       = SELECT alias.goto FROM alias,alias_domain,domain WHERE alias_domain.alias_domain='%d' AND alias.address=CONCAT('%u', '@',     alias_domain.target_domain) AND alias_domain.target_domain=domain.domain AND alias.active=1 AND alias_domain.active=1 AND domain.backu    pmx=0

Check domain status in virtual_mailbox_maps, virtual_alias_maps

  • Edit /etc/postfix/mysql_virtual_mailbox_maps.cf, change query = to below new setting:
File: mysql_virtual_mailbox_maps.cf
query       = SELECT CONCAT(mailbox.storagenode, '/', mailbox.maildir) FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.active='1' AND mailbox.enabledeliver='1' AND domain.domain = mailbox.domain AND domain.active='1'
  • Edit /etc/postfix/mysql_virtual_alias_maps.cf, change query = to below new setting:
File: mysql_virtual_alias_maps.cf
query       = SELECT alias.goto FROM alias,domain WHERE alias.address='%s' AND alias.active=1 AND domain.backupmx=0 AND domain.active=1

It will now check domain status, so if this domain is disabled, all users and aliases will be disabled too.

Make catch-all account work as expected

To make catch-all account work as expected, we need two more SQL lookup files:

  • /etc/postfix/catchall_maps.cf: Catch-all support for exist domains.
  • /etc/postfix/domain_alias_catchall_maps.cf: Catch-all support for alias domains.

Now edit postfix config file /etc/postfix/main.cf (Linux) or /usr/local/etc/postfix/main.cf (FreeBSD), append these two lookup files in virtual_alias_maps setting:

File: main.cf
virtual_alias_maps =
    proxy:mysql:/etc/postfix/mysql/virtual_alias_maps.cf,
    proxy:mysql:/etc/postfix/mysql/domain_alias_maps.cf,
    proxy:mysql:/etc/postfix/catchall_maps.cf,                      # <- Add this line
    proxy:mysql:/etc/postfix/domain_alias_catchall_maps.cf        # <- Add this line.

Now create these two new files:

  • /etc/postfix/catchall_maps.cf:
File: catchall_maps.cf
user        = vmail
password    = PASSWORD_OF_VMAIL
hosts       = 127.0.0.1
port        = 3306
dbname      = vmail
query       = SELECT alias.goto FROM alias,domain WHERE alias.address='%d' AND alias.address=domain.domain AND alias.active=1 AND domain.active=1 AND domain.backupmx=0
  • /etc/postfix/domain_alias_catchall_maps.cf
File: domain_alias_catchall_maps.cf
user        = vmail
password    = PASSWORD_OF_VMAIL
hosts       = 127.0.0.1
port        = 3306
dbname      = vmail
query       = SELECT alias.goto FROM alias,alias_domain,domain WHERE alias_domain.alias_domain='%d' AND alias.address=alias_domain.target_domain AND alias_domain.target_domain=domain.domain AND alias.active=1 AND alias_domain.active=1

Restart postfix to make it work.

Update SQL structure of vmail database

  • Add some more columns:
Terminal:
$ mysql -uroot -p
USE vmail;

-- enablesmtpsecured: Used for SMTP over SSL support in Postfix + Dovecot.
ALTER TABLE mailbox ADD COLUMN enablesmtpsecured TINYINT(1) NOT NULL DEFAULT '1';

-- name: Used to store common name of admin and alias account.
ALTER TABLE admin ADD COLUMN name VARCHAR(255) DEFAULT '' COLLATE utf8_general_ci;
ALTER TABLE alias ADD COLUMN name VARCHAR(255) DEFAULT '' COLLATE utf8_general_ci;

-- passwordlastchange: Store date of password last change.
ALTER TABLE admin ADD COLUMN passwordlastchange DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE mailbox ADD COLUMN passwordlastchange DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';

-- local_part: Used for PostfixAdmin compatible.
ALTER TABLE mailbox ADD COLUMN local_part VARCHAR(255) NOT NULL DEFAULT '';

-- defaultuseraliases: Assign new user to these aliases
ALTER TABLE domain ADD COLUMN defaultuseraliases TEXT NOT NULL DEFAULT '';

-- defaultpasswordscheme: Per-domain password scheme support.
ALTER TABLE domain ADD COLUMN defaultpasswordscheme VARCHAR(10) NOT NULL DEFAULT '';
  • Create indexes of some columns for better performance.
Terminal:
$ mysql -uroot -p
USE vmail;

-- Table: admin
ALTER TABLE  admin ADD INDEX (passwordlastchange);
ALTER TABLE  admin ADD INDEX (expired);
ALTER TABLE  admin ADD INDEX (active);

-- Table: alias
ALTER TABLE  alias ADD INDEX (domain);
ALTER TABLE  alias ADD INDEX (expired);
ALTER TABLE  alias ADD INDEX (active);

-- Table: domain
ALTER TABLE  domain ADD INDEX (backupmx);
ALTER TABLE  domain ADD INDEX (expired);
ALTER TABLE  domain ADD INDEX (active);

-- Table: domain_admins
ALTER TABLE  domain ADD INDEX (username);
ALTER TABLE  domain ADD INDEX (domain);
ALTER TABLE  domain ADD INDEX (active);

-- Table: mailbox
ALTER TABLE  mailbox ADD INDEX (domain);
ALTER TABLE  mailbox ADD INDEX (department);
ALTER TABLE  mailbox ADD INDEX (employeeid);
ALTER TABLE  mailbox ADD INDEX (enablesmtp);
ALTER TABLE  mailbox ADD INDEX (enablesmtpsecured);
ALTER TABLE  mailbox ADD INDEX (enablepop3);
ALTER TABLE  mailbox ADD INDEX (enablepop3secured);
ALTER TABLE  mailbox ADD INDEX (enableimap);
ALTER TABLE  mailbox ADD INDEX (enableimapsecured);
ALTER TABLE  mailbox ADD INDEX (enablemanagesieve);
ALTER TABLE  mailbox ADD INDEX (enablemanagesievesecured);
ALTER TABLE  mailbox ADD INDEX (enablesieve);
ALTER TABLE  mailbox ADD INDEX (enablesievesecured);
ALTER TABLE  mailbox ADD INDEX (enableinternal);
ALTER TABLE  mailbox ADD INDEX (passwordlastchange);
ALTER TABLE  mailbox ADD INDEX (expired);
ALTER TABLE  mailbox ADD INDEX (active);

-- Table: sender_bcc_domain
ALTER TABLE  sender_bcc_domain ADD INDEX (bcc_address);
ALTER TABLE  sender_bcc_domain ADD INDEX (expired);
ALTER TABLE  sender_bcc_domain ADD INDEX (active);

-- Table: sender_bcc_user
ALTER TABLE  sender_bcc_user ADD INDEX (bcc_address);
ALTER TABLE  sender_bcc_user ADD INDEX (expired);
ALTER TABLE  sender_bcc_user ADD INDEX (active);

-- Table: recipient_bcc_domain
ALTER TABLE  recipient_bcc_domain ADD INDEX (bcc_address);
ALTER TABLE  recipient_bcc_domain ADD INDEX (expired);
ALTER TABLE  recipient_bcc_domain ADD INDEX (active);

-- Table: recipient_bcc_user
ALTER TABLE  recipient_bcc_user ADD INDEX (bcc_address);
ALTER TABLE  recipient_bcc_user ADD INDEX (expired);
ALTER TABLE  recipient_bcc_user ADD INDEX (active);
Personal tools