// <ahref="./index.html">Document Index</a></div><h1id="upgrade-iredmail-from-061-to-070">Upgrade iRedMail from 0.6.1 to 0.7.0</h1>
<li>Edit <code>/etc/postfix/mysql_domain_alias_maps.cf</code>, change <code>query =</code> to below new setting:</li>
</ul>
<pre><code># Part of 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.backupmx=0
</code></pre>
<h3id="check-domain-status-in-postfix-and-dovecot">Check domain status in postfix and dovecot</h3>
<pre><code># Part of 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'
</code></pre>
<p><strong>WARNING</strong>: If you don't have column <code>storagenode</code> present in table
<code>vmail.mailbox</code>, please add it with below SQL command:</p>
<pre><code>$ mysql -uroot -p
mysql> USE vmail;
mysql> ALTER TABLE mailbox ADD COLUMN storagenode VARCHAR(255) NOT NULL DEFAULT '';
<pre><code># Part of file: mysql_virtual_alias_maps.cf
query = SELECT alias.goto FROM alias,domain WHERE alias.address='%s' AND alias.domain='%d' AND alias.domain=domain.domain AND alias.active=1 AND domain.backupmx=0 AND domain.active=1
<pre><code># Part of file: 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.active=1 AND mailbox.enabledeliver=1 AND domain.backupmx=0 AND domain.active=1 AND mailbox.transport<>''
<pre><code># Part of file: mysql_sender_login_maps.cf
query = SELECT mailbox.username FROM mailbox,domain WHERE mailbox.username='%s' AND mailbox.domain='%d' AND mailbox.domain=domain.domain AND mailbox.enablesmtp=1 AND mailbox.active=1 AND domain.backupmx=0 AND domain.active=1
change <code>query =</code> to below new setting:</li>
</ul>
<pre><code># Part of file: mysql_recipient_bcc_maps_user.cf
query = SELECT recipient_bcc_user.bcc_address FROM recipient_bcc_user,domain WHERE recipient_bcc_user.username='%s' AND recipient_bcc_user.domain='%d' AND recipient_bcc_user.domain=domain.domain AND domain.backupmx=0 AND domain.active=1 AND recipient_bcc_user.active=1
</code></pre>
<ul>
<li>Edit postfix config file <code>mysql_sender_bcc_maps_user.cf</code>, change <code>query =</code> to
below new setting:</li>
</ul>
<pre><code># Part of file: mysql_sender_bcc_maps_user.cf
query = SELECT sender_bcc_user.bcc_address FROM sender_bcc_user,domain WHERE sender_bcc_user.username='%s' AND sender_bcc_user.domain='%d' AND sender_bcc_user.domain=domain.domain AND domain.backupmx=0 AND domain.active=1 AND sender_bcc_user.active=1
</code></pre>
<ul>
<li>Edit dovecot config file <code>/etc/dovecot-mysql.conf</code> (RHEL/CentOS) or
<code>/etc/dovecot/dovecot-mysql.conf</code> (Debian/Ubuntu/openSUSE) or
user_query = SELECT CONCAT(mailbox.storagebasedirectory, '/', mailbox.storagenode, '/', mailbox.maildir) AS home, CONCAT('*:bytes=', mailbox.quota*1048576) AS quota_rule FROM mailbox,domain WHERE mailbox.username='%u' AND mailbox.domain='%d' AND mailbox.enable%Ls%Lc=1 AND mailbox.domain=domain.domain AND mailbox.active=1 AND domain.backupmx=0 AND domain.active=1
</code></pre>
<p>It will now check domain status, so if this domain is disabled, all users and
aliases will be disabled too.</p>
<p>Restart postfix and dovecot services to make it work.</p>
<h3id="make-catch-all-account-work-as-expected">Make catch-all account work as expected</h3>
<p>To make catch-all account work as expected, we need two more SQL lookup files:</p>
<pre><code>* `/etc/postfix/catchall_maps.cf`: Catch-all support for exist domains.
* /etc/postfix/domain_alias_catchall_maps.cf: Catch-all support for alias domains.
</code></pre>
<p>Now edit postfix config file <code>/etc/postfix/main.cf</code> (Linux) or
<code>/usr/local/etc/postfix/main.cf</code> (FreeBSD), append these two lookup files in
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
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
</code></pre>
<p>Restart postfix to make it work.</p>
<h3id="update-sql-structure-of-vmail-database">Update SQL structure of <code>vmail</code> database</h3>
<ul>
<li>Add some more columns:</li>
</ul>
<pre><code>$ 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 '';
refer to this tutorial: <ahref="./force.user.to.change.password.html">Force users to change password in 90 days</a>.</p><divclass="footer">
<pstyle="text-align: center; color: grey;">All documents are available in <ahref="https://bitbucket.org/zhb/iredmail-docs/src">BitBucket repository</a>, and published under <ahref="http://creativecommons.org/licenses/by-nd/3.0/us/"target="_blank">Creative Commons</a> license. You can <ahref="https://bitbucket.org/zhb/iredmail-docs/get/tip.tar.bz2">download the latest version</a> for offline reading. If you found something wrong, please do <ahref="http://www.iredmail.org/contact.html">contact us</a> to fix it.</p>