IRedMail/FAQ/Share.IMAP.Folder

From iRedMail

(Difference between revisions)
Jump to: navigation, search
(Test shared folder)
(Test shared folder)
Line 111: Line 111:
</pre>}}
</pre>}}
-
* Log into roundcube webmail with account testing@a.cn. And you can now see the shared folder. See [http://screenshots.iredmail.googlecode.com/hg/iredmail/roundcube/imap-share-folder.png |screenshot here]
+
* Log into roundcube webmail with account testing@a.cn. And you can now see the shared folder. See [http://screenshots.iredmail.googlecode.com/hg/iredmail/roundcube/imap-share-folder.png screenshot here]
* After you shared folder with 'SETACL' command, dovecot will insert a record in MySQL database (table '''share_folder'''):
* After you shared folder with 'SETACL' command, dovecot will insert a record in MySQL database (table '''share_folder'''):

Revision as of 04:42, 17 January 2011

Contents


Summary

Configure Dovecot

  • Add ACL plugins in lda and imap:
File: dovecot.conf
protocol lda {
    mail_plugins = ... acl
}

protocol imap {
    mail_plugins = ... acl imap_acl
}
  • Add necessary NAMESPACE and ACL config:
File: dovecot.conf
namespace private {
  separator = / 
  prefix =
  #location defaults to mail_location.
  inbox = yes 
}

namespace shared {
  separator = / 
  prefix = shared/%%u/
  location = maildir:/%%Lh/Maildir/:INDEX=/%L%h/Maildir/shared/%%u
  subscriptions = no 
  list = children
}

plugin {
    acl = vfile
}

With the above configuration it's possible to open shared mailboxes if you know their name, but they won't be visible in the mailbox list. This is because Dovecot has no way of knowing what users have shared mailboxes to whom. Iterating through all users and looking inside their mail directories would be horribly inefficient for more than a couple users.

To overcome this problem Dovecot needs a dictionary, which contains the list of users who have shared mailboxes and to whom they have shared. If the users aren't properly listed in this dictionary, their shared mailboxes won't be visible. Currently there's no way to automatically rebuild this dictionary, so make sure it doesn't get lost. If it does, each user having shared mailboxes must use the IMAP SETACL command (see below) to get the dictionary updated for themselves.

File: dovecot.conf
plugin {
    acl_shared_dict = proxy::acl
}
dict {
    acl = mysql:/etc/dovecot/dovecot-share-folder.conf
}
  • Create mysql lookup file: /etc/dovecot/dovecot-share-folder.conf:
File: /etc/dovecot/dovecot-share-folder.conf
connect = host=localhost dbname=vmail user=vmailadmin password=cZ0LFtKO7eqXzOzxruwbZ4h2F2PqkJ
map {
    pattern = shared/shared-boxes/user/$to/$from
    table = share_folder
    value_field = dummy

    fields {
        from_user = $from
        to_user = $to
    }
}

Note: MySQL user name must be vmailadmin or other users which have read/write privileges.

  • Create database in MySQL database: vmail.
Terminal:
$ mysql -uroot -p
mysql> USE vmail;
mysql> CREATE TABLE IF NOT EXISTS share_folder (
->  from_user VARCHAR(150) NOT NULL,
->  to_user VARCHAR(150) NOT NULL,
->  dummy CHAR(1),
->  PRIMARY KEY (from_user, to_user)
-> );

Configure Roundcube Webmail

Roundcube-0.5 supports shared IMAP folder, with one config setting in main.inc.php:

File: main.inc.php
// imap's folder delimiter
$rcmail_config['imap_delimiter'] = "/";

// Leave below settings as "null".
$rcmail_config['imap_ns_personal'] = null;
$rcmail_config['imap_ns_other']    = null;
$rcmail_config['imap_ns_shared']   = null;

Test shared folder

Please restart dovecot and apache web server after you modified dovecot and roundcube.

  • Set a share folder with telnet.
Terminal:
# telnet localhost 143
* OK [...] Dovecot ready.

. login from@domain.ltd passwd           # <- Login with your email address and password.
. OK [... ACL ..] Logged in

. SETACL archive testing@a.cn rl          # <- Share folder 'archive' to user testing@a.cn, allow to read (r) and lookup (l).
. OK Setacl complete.
^]
telnet> quit
  • Log into roundcube webmail with account testing@a.cn. And you can now see the shared folder. See screenshot here
  • After you shared folder with 'SETACL' command, dovecot will insert a record in MySQL database (table share_folder):
Terminal:
# mysql -uroot -p
mysql> USE vmail;
mysql> SELECT * FROM share_folder;
+--------------+--------------+-------+
| from_user    | to_user      | dummy |
+--------------+--------------+-------+
| www@a.cn     | testing@a.cn | 1     |
+--------------+--------------+-------+

References

Personal tools