Remove attachments
"Oliver" == Oliver Glas <oliver.glas@inss.ch> writes:
I am looking for a way to remove attachments, based on a condition. Like attachments starting with "TimeReport" shall be removed, and then the mail should be delivered, with all other attachments.
This is not a solution that dovecat can work with. You need to use a milter in your mailserver (like postfix) which can strip out mime attachements or do other modifications to an email before it's delivered to the mailbox.
I did so far not find a solution to remove attachments. Do I need a plugin / extension ? If so, how to implement and use that ?
milters are what you want. MIMEdefang is one.
John
"Oliver" == Oliver Glas <oliver.glas@inss.ch> writes:
https://mimedefang.org/ is where I'd go to look for details on how to implement it. I haven't done it myself.
Is it possible to get a documentation for that ? Or a description how to implement that ?
Am 03.06.23 um 23:28 schrieb John Stoffel:
"Oliver" == Oliver Glas <oliver.glas@inss.ch> writes:
I am looking for a way to remove attachments, based on a condition. Like attachments starting with "TimeReport" shall be removed, and then the mail should be delivered, with all other attachments.
This is not a solution that dovecat can work with. You need to use a milter in your mailserver (like postfix) which can strip out mime attachements or do other modifications to an email before it's delivered to the mailbox.
I did so far not find a solution to remove attachments. Do I need a plugin / extension ? If so, how to implement and use that ?
milters are what you want. MIMEdefang is one.
John
On 2023-06-06 1:36 p.m., John Stoffel wrote:
"Oliver" == Oliver Glas <oliver.glas@inss.ch> writes: https://mimedefang.org/ is where I'd go to look for details on how to implement it. I haven't done it myself.
Most likely in the "filter" function of "mimedefang-filter" perl script:
#*********************************************************************** # %PROCEDURE: filter # %ARGUMENTS: # entity -- a Mime::Entity object (see MIME-tools documentation for details) # fname -- the suggested filename, taken from the MIME Content-Disposition: # header. If no filename was suggested, then fname is "" # ext -- the file extension (everything from the last period in the name # to the end of the name, including the period.) # type -- the MIME type, taken from the Content-Type: header. # # NOTE: There are two likely and one unlikely place for a filename to # appear in a MIME message: In Content-Disposition: filename, in # Content-Type: name, and in Content-Description. If you are paranoid, # you will use the re_match and re_match_ext functions, which return true # if ANY of these possibilities match. re_match checks the whole name; # re_match_ext checks the extension. See the sample filter below for usage. # %RETURNS: # Nothing # %DESCRIPTION: # This function is called once for each part of a MIME message. # There are many action_*() routines which can decide the fate # of each part; see the mimedefang-filter man page. #***********************************************************************
Within the "filter" function, there are several options (actions) on what to do with the MIME entity: e.g. "action_drop", "action_drop_with_warning", "action_replace_with_warning" https://mimedefang.org/man_Mail::MIMEDefang::Actions.html
On 2023-06-03, John Stoffel <john@stoffel.org> wrote:
"Oliver" == Oliver Glas <oliver.glas@inss.ch> writes:
I am looking for a way to remove attachments, based on a condition. Like attachments starting with "TimeReport" shall be removed, and then the mail should be delivered, with all other attachments.
This is not a solution that dovecat can work with. You need to use a milter in your mailserver (like postfix) which can strip out mime attachements or do other modifications to an email before it's delivered to the mailbox.
I did so far not find a solution to remove attachments. Do I need a plugin / extension ? If so, how to implement and use that ?
milters are what you want. MIMEdefang is one.
You can also do this by calling altermime from sieve with the vnd.dovecot.filter extension from https://doc.dovecot.org/configuration_manual/sieve/plugins/extprograms/
If you want to do that on Dovecot's side, look for sieve and vnd.dovecot.filter. See https://doc.dovecot.org/configuration_manual/sieve/plugins/extprograms/ and corresponding RFC for details.
Doing that directly in Dovecot might not be the most effective way but depends on your needs... Anyway, it would require a bit of scripting, basically you need to parse the message for MIME structure, find the "attachment" part, remove it, reassemble and return.
Depending on your stack, you may take a look at the more effective place to do the filtering (as John Stoffel mentioned) -- e. g. many antivirus/antispam filters have the ability to filter out attachments... But if that's primarily for a single user or there's no way to plug it in prior Dovecot, it could fit perfectly.
Tomas
On Sat, Jun 03, 2023 at 10:07:20AM +0200, Oliver Glas wrote:
Hello,
I am looking for a way to remove attachments, based on a condition. Like attachments starting with "TimeReport" shall be removed, and then the mail should be delivered, with all other attachments.
I did so far not find a solution to remove attachments. Do I need a plugin / extension ? If so, how to implement and use that ?
Greetings, Oliver Glas
dovecot mailing list -- dovecot@dovecot.org To unsubscribe send an email to dovecot-leave@dovecot.org
participants (5)
-
John Stoffel
-
Oliver Glas
-
Oscar del Rio
-
Stuart Henderson
-
Tomas Habarta