Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would want to use regex to do fancy masquerading #175

Closed
tardich opened this issue Jan 11, 2024 · 4 comments
Closed

Would want to use regex to do fancy masquerading #175

tardich opened this issue Jan 11, 2024 · 4 comments

Comments

@tardich
Copy link

tardich commented Jan 11, 2024

Hello. I'm looking at a way to replace anyuser@int.this.fake.domain with anyuser@this.real.domain.com

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)

@bokysan
Copy link
Owner

bokysan commented Jan 11, 2024

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.

@tardich
Copy link
Author

tardich commented Jan 11, 2024

Ah good insight! Forgot that :-( I'll take a look at it, meanwhile

@tardich
Copy link
Author

tardich commented Jan 11, 2024

OK, I made it working. Here's what I did.

  1. 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
  2. Created and mounted the pcre map as /etc/postfix/generic.pcre from a secret again, containing in my case: /([a-z]+)@int.fake.stba/ $1@int.real.ca
  3. Added config.postfix.smtp_generic_maps: "pcre:/etc/postfix/generic.pcre" as a value to the deployment

And then test. A message, originating from myuser@int.fake.stba is now actually sent to myuser@int.real.ca, 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/ $1@int.real.ca", 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 :-)

@bokysan
Copy link
Owner

bokysan commented Apr 23, 2024

Latest image (currently in master branch only) now includes install of postfix-pcre.

@bokysan bokysan closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants