Question: PMG – Relay based on recipient domain’s MX record (like in Mailcow)
Hi everyone,
I’m currently setting up Proxmox Mail Gateway (PMG) as a front-end mail filter and relay.
What I’m trying to achieve is a routing logic based on the MX record of the recipient domain, not just a static domain-to-host mapping.
Example use case:
So the idea is:
- PMG is listed as the public MX in DNS (e.g. `example.com MX 10 pmg.example.net`)
- When PMG receives the email, it should:
- Look up the MX record of the recipient domain (e.g. `mx1.pmg-mail.de `)
- Based on that MX, decide where to relay the message internally (e.g. to `mail1.targetserver.de`)
I’ve already implemented this in Mailcow, where it works well using `transport_maps`, e.g.:
The reason we want to do this dynamically is because we are hosting a large number of domains, and manually maintaining static transport rules for each one is not feasible.
We will synchronize the list of accepted/relayed domains into PMG via the API — unless there is a better or recommended way to manage that as well?
Is there any way to implement this kind of MX-dependent routing in PMG?
Or would we need to use an external script and the PMG API to regularly update transport rules based on the current MX values?
Is there any way to implement this kind of MX-dependent routing in PMG?
Or would I need to use an external script and the PMG API to regularly update transport rules based on the current MX values?
I’m aware that PMG allows static transport mappings per domain, but that’s not ideal in this case – I want the routing to be dynamic based on the DNS MX, without having to manage every domain manually.
Thanks in advance for any insights or ideas!
Hi everyone,
I’m currently setting up Proxmox Mail Gateway (PMG) as a front-end mail filter and relay.
What I’m trying to achieve is a routing logic based on the MX record of the recipient domain, not just a static domain-to-host mapping.
Example use case:
Code:
Recipient Domain | Public MX Record | Desired Internal Relay Target
-------------------|------------------------|-------------------------------
domain1.de | mx1.pmg-mail.de | mail1.targetserver.de
domain2.de | mx2.pmg-mail.de | mail2.targetserver.de
domain3.de | mx3.pmg-mail.de | mail3.targetserver.de
So the idea is:
- PMG is listed as the public MX in DNS (e.g. `example.com MX 10 pmg.example.net`)
- When PMG receives the email, it should:
- Look up the MX record of the recipient domain (e.g. `mx1.pmg-mail.de `)
- Based on that MX, decide where to relay the message internally (e.g. to `mail1.targetserver.de`)
I’ve already implemented this in Mailcow, where it works well using `transport_maps`, e.g.:
Code:
domain1.de mx: mx1.pmg-mail.de → relay: mail1.targetserver.de
The reason we want to do this dynamically is because we are hosting a large number of domains, and manually maintaining static transport rules for each one is not feasible.
We will synchronize the list of accepted/relayed domains into PMG via the API — unless there is a better or recommended way to manage that as well?
Is there any way to implement this kind of MX-dependent routing in PMG?
Or would we need to use an external script and the PMG API to regularly update transport rules based on the current MX values?
Is there any way to implement this kind of MX-dependent routing in PMG?
Or would I need to use an external script and the PMG API to regularly update transport rules based on the current MX values?
I’m aware that PMG allows static transport mappings per domain, but that’s not ideal in this case – I want the routing to be dynamic based on the DNS MX, without having to manage every domain manually.
Thanks in advance for any insights or ideas!
