Thank you for your ideas. Regardless of your understanding of why I’m using pmg, a solution would be nice. It is currently not possible to do it without pmg. I asked the mailow company for support some time ago but didn’t get any response. Perhaps the mail got lost in space 🙂. So self is the man.
I found a way. This is not ideal yet, but it works for now and should survive an update. It could bring some problems if mailcow changes the handling of incoming mails from the clients. So it need to be verified before each update. In case anyone needs a similar solution, here’s what I did:
In the folder “/opt/mailcow-dockerized/data/conf/postfix”
cp anonymize_headers.pcre extra_modify_headers.pcre
edit “extra_modify_headers.pcre” and add the following line at the bottom
/^Subject: (.*)$/ FILTER smtp:PMGSERVER
edit “extra.cf” and add the following line at the bottom
smtp_header_checks = pcre:/opt/postfix/conf/extra_modify_headers.pcre
restart docker postfix container and done.
Also set sender dependent transport for every domain in mailcow GUI.
Mailcow uses postfix to replace the headers of mails from the clients at port 465,587. Incoming mails on port 25 doesn’t need the replacement. The rules to edit the header are placed in the “anonymize_headers.pcre” file. The file will be overwritten by mailcow updates, so this must be copied. I added a rule to set a new filter for the mail. The filter is reachable through smtp as the line shows. I choose one header which should match every mail. Setting any header would increase postfix logs a lot because the filter would be set again and again for every matching header. After the mail passed the first queue the mail will be send to the filter in this case pmg. pmg can now do its work and then send the mail back to mailcow at port 25. Here the mail get processed normally like every other external mail. The “extra.cf” file is used by mailcow for custom modifications at the main.cf. So it survive updates.
My frist idea was to edit the master.cf but this will not survive updates. At the moment mailcow only accept custom main.cf entries as I could see in the docs.
If someone knows another solution, it would be nice if we exchange ideas.