How can I remove specific attachments from mails in dovecot sieve mail server ? I have tried several configurations but the attachments were not removed. But it did not know keyword "replace" and I don't know what it requires. I am using https://github.com/docker-mailserver/docker-mailserver. Do I need a plugin or extenstion for doing that ? Or what is the simplest configuration to do that ?
I tried
replace :mime :contenttype "text/plain" "This email originally contained an attachment, which has been removed.";
As I mentioned here, you have to use sieve
extprogramsplugin to filter incoming messages. Vanilla dovecot does not have specific sieve plugin to modify part of multipart MIME message.First of all, you'll need to edit dovecot's
90-sieve.confto enable+vnd.dovecot.filter:Specify program location in
90-sieve-extprograms.conf:Create these directories:
Then, write some filter program to strip attachments like following:
Save this script as
/etc/dovecot/sieve-filter/strip_attachments.pyand make it executable:Your sieve script should look like following: