docker-postfix
docker-postfix copied to clipboard
Would want to use regex to do fancy masquerading
Hello. I'm looking at a way to replace [email protected] with [email protected]
I know I can do this by using smtp_generic_maps, but I'd need to specify all "internal" senders, one by one to something decent externally.
I'd prefer using a regex to do so. And this can be done with postfix-pcre regex module. Documentation to do so is at: https://serverfault.com/questions/930819/postfix-smtp-generic-maps-with-regular-expression
Would be really nice to have that included (the package, at least)
Sure, that does sound something that could be added. While it's not, you're free to create your own init script, mount it to /docker-init.db
and it will be executed automatically on startup.
Ah good insight! Forgot that :-( I'll take a look at it, meanwhile
OK, I made it working. Here's what I did.
- Created and mounted an init script to install postfix-pcre module from a secret (with the help of extraVolumes and extraVolumeMounts). This portion should be done at the docker image creation level I'd say
- Created and mounted the pcre map as /etc/postfix/generic.pcre from a secret again, containing in my case: /([a-z]+)@int.fake.stba/ [email protected]
- Added config.postfix.smtp_generic_maps: "pcre:/etc/postfix/generic.pcre" as a value to the deployment
And then test. A message, originating from [email protected] is now actually sent to [email protected], which was the expected result.
Even more, this could be a little more templated from Helm to make it a little more seemlessly accessible. Something, maybe, like pcre.map: "/([a-z]+)@int.fake.stba/ [email protected]", pcre.enabled: true, and pcre.filename: somefilename.pcre that could create the secret (or configMap) with the content, mount it to /etc/postfix/somefilename.pcre, and add smtp_generic_maps: pcre:/etc/postfix/somefilename.pcre to /etc/postfix/main.cf
This would be the ultimate goal, but I can live without it :-)
Latest image (currently in master
branch only) now includes install of postfix-pcre
.