IRedMail/FAQ/Share.IMAP.Folder
From iRedMail
(→Summary) |
(→Test shared folder) |
||
| Line 118: | Line 118: | ||
. SETACL archive testing@a.cn rl # <- Share folder 'archive' to user testing@a.cn, allow to read (r) and lookup (l). | . SETACL archive testing@a.cn rl # <- Share folder 'archive' to user testing@a.cn, allow to read (r) and lookup (l). | ||
. OK Setacl complete. | . OK Setacl complete. | ||
| - | ^] | + | ^] # <- Ctrl + ] |
telnet> quit | telnet> quit | ||
</pre>}} | </pre>}} | ||
Revision as of 04:59, 17 January 2011
Contents |
Note: Mailbox sharing is enabled by default in iRedMail-0.7.0.
Summary
With Dovecot-1.2, it's possible to share your IMAP folders to other users. This article describes:
- How to enable mailbox sharing in Dovecot
- How to enable mailbox sharing in Roundcube webmail.
- How to test mailbox sharing with telnet
Requirements
- Dovecot >= 1.2. If you're using 1.1, please follow this detail tutorial to upgrade it.
- Roundcube Webmail >= 0.5 -stable release.
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. If you're using Thunderbird, there's a add-on available (listed in references section).
| 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. ^] # <- Ctrl + ] 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
- BigMichi1's contribution
- Dovecot wiki: Mailbox sharing between users (v1.2+)
- Imap-ACL-Extension for Thunderbird, manage acls/permissions for shared mailboxes/folders on imap servers.
