Cyrus IMAP autocreate Inbox patch ---------------------------------- NOTE : This patch has been created at the University of Athens. For more info, as well as more patches on Cyrus IMAPD server, please visit http://email.uoa.gr The design of Cyrus IMAP server does not predict the automatic creation of users' INBOX folders. The creation of a user's INBOX is considered to be an external task, that has to be completed as part of the user e-mail account creation procedure. Hence, to create a new e-mail account the site administrator has to a) Include the new account in the user database for the authentication procedure (e.g. sasldb, shadow, mysql, ldap). b) Create the corresponding INBOX folder. Alternatively, the user, if succesfully authenticated, may create his own INBOX folder, as long as the configuration of the site allows it (see "autocreatequota" in imapd.conf). Unlike what uncareful readers may think, enabling the "autocreatequota" option, doesn't lead to the automatic INBOX folder creation by Cyrus IMAP server. In fact, "autocreate" means that the IMAP clients are allowed to automatically create the user INBOX. This patch adds the functionality of automatic creation of the users' INBOX folders into the Cyrus IMAP server. It is implemented as two features, namely the "create on login" and "create on post". Create on login =============== This feauture provides automatic creation of a user's INBOX folder when all of the following requirements are met: i) The user has succesfully passed the authentication procedure. ii) The user's authorization ID (typically the same as the user's authentication ID) doesn't belong to the imap_admins or admins accounts (see imapd.conf). iii) The "autocreatequota" option in the imap configuration file has been set to a non zero value. iv) The corresponding to the user's authorizationID INBOX folder does not exist. The user's first login is the most typical case when all four requirements are met. Note that if the authenticatedID is allowed to proxy to another account for which all of the above requirements are met, the corresponding INBOX folder for that account will be created. Create on post ============== This feauture provides automatic creation of a user's INBOX folder when all of the following requirements are met. i) An e-mail message addressed to the user has been received. ii) The recipient is not any of the imap_admins or admins accounts. Note that passing e-mails to admins or imap_admins accounts from the MTA to LMTP should be avoided in any case. iii) The recipient's INBOX does not exist. iv) The "autocreatequota" option in the imap configuration file has been set to a non zero value. v) The "createonpost" option in the imap configuration file has been switched on. Besides the automatic creation of INBOX folder, additional functionalities are provided: A) Automatic creation of INBOX subfolders controlled by "autocreateinboxfolders" configuration option. e.g autocreateinboxfolders: sent|drafts|spam|templates B) Automatic subscription of INBOX subfolders controlled by "autosubscribeinboxfolders" configuration option. e.g autosubscribeinboxfolders: sent|spam Obviously, only subscription to subfolders included in the "autocreateinboxfolder" list is meaningfull. C) Automatic subscription to shared folders (bulletin boards). The user gets automatically subscribed to the shared folders declared in the "autosubscribesharedfolders" configuration option in imapd.conf. e.g autosubscribesharedfolders: public_folder | public_folder.subfolder In order the above action to succeed, the shared folder has to pre-exist the INBOX creation and the user must have the apropriate permissions in order to be able to subscribe to the shared folder. * A new config option has been added. 'autosubscribe_all_sharedfolders' is a yes/no option. When set to yes, the user is automatically subscribed to all shared one has permission to subscribe to. Please, note that when this option is set to yes, then 'autosubscribesharedfolders' option is overriden. D) Automatic creation of a predefined default sieve script. This is very useful when a default sieve script is used for every user. Usually, a default anti-spam script may me be written in a file and copied to each user sieve scripts upon the INBOX creation. The imapd.conf option that has been added is 'autocreate_sieve_script'. This refers to the full path of the file that contains the sieve script. eg. autocreate_sieve_script: /etc/default_sieve_script In order this functionality to work, the following requirements must have been met: - 'sieveusehomedir' option must be 'no' in the configuration (default). - 'sievedir' option must have a valid value. NOTE : Currently, this patch does not check the validity of the sieve script file. The administrator should make sure that the provided file contains a valid sieve script. Issues to be considered ======================= I) In order to use the create on post feauture one should be absolutely sure that: a) The MTA checks the validity of the e-mail recipient before sending the e-mail to LMTP. This is an RFC821 requirement. This usually expands to "the mta should be able to use the account database as user mailbox database". b) Only authorized accounts/services can talk to LMTP. II) Especially in the case of imap logins, the current patch implementation checks for the INBOX folder existence upon login, causing an extra mailbox lookup in most of the cases. A better approach would be to chase the "IMAP_MAILBOX_NONEXISTENT" error code and check if the error is associated with an INBOX folder. However, this would mess up Cyrus code. The way it was implemented may not have been the most performance optimized, but it produces a much cleaner and simple patch. Things to be done ================= 1. Support MURDER architecture. 2. Support virtual domains. For more information and updates please visit http://email.uoa.gr/autocreate