Blocking mail deletion in Dovecot from the mail client
An interesting task came up. I needed to make it so that even if the user has “delete messages from the server” set in the mail software - the messages still stay on the server, that is they are not deleted. This applied both to the incoming and to the outgoing mail.
Software: dovecot 2.2.13. Install dovecot with any package manager.
OS: Debian 7.x
After that you will have to edit several files. The first thing we need to do is create the global-acls folder in the /etc/dovecot directory and create 2 files there: INBOX and Sent with the following contents:
owner lrwsipka authenticated lrwsipka
After that go into the conf.d directory and edit the two files 20-imap.conf and 20-pop3.conf
Bring the mail_plugins lines to the following form:
imap:mail_plugins = $mail_plugins quota imap_quota acl
pop3:mail_plugins = $mail_plugins quota acl
Also edit 10-mail.conf so that we have the folders: Sent, Trash and so on.
namespace inbox {
inbox = yes mailbox Drafts {
auto = subscribe special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
auto = subscribe special_use = \Sent
}
mailbox "Sent Messages" {
auto = subscribe special_use = \Sent
}
mailbox Trash {
auto = subscribe special_use = \Trash
}
}
Restart dovecot and check. In the web client (roundcube) an attempt to delete a message gives the error: Access denied. With programs like OutLook you have to configure the IMAP folder synchronization so that everything works correctly.