How, if possible, copy all incoming mail with attachments to mybackup@example.net
If I use sender_bcc_map = type:table
– all mails will be copied, without attachments too. I do not need that, I just need email with attachments.
My postfix version was 2.10.
Best Answer
Basically Postfix can detects whether an email has attachment or not by parsing the header. And for that, postfix has feature called header_checks and its variation. RFC 2183 section 2.2 defined that an attachment should be use
Content-Dispostion: attachment;
header. So, we can usemime_header_checks
to detects an attachment then tell postfix to copy (BCC) it.Further info: Postfix BUILTIN_FILTER_README and Filter mail attachments
FYI, Postfix doesn't have concept incoming and outgoing email. All email passed through postfix was considered coming from other client and postfix relay it, to other mailserver, LMTP server, mailbox and others. So I'm afraid that this method will affect your emails, both incoming and outgoing (with some exception below).
If your outgoing email source was sendmail (
mail
command) or submitted via submission (587) or submitted through IP Address 127.0.0.1, you can selectively turn off the header_checks. Specify this configuration inmaster.cf
Source: Turning Off Body & Header Checks for Internal Users