SMTP Gateway Post PMG

infinityM

Member
Dec 7, 2019
172
1
18
30
Hey Guys,

Ok so i've got a Direct Admin server which passes all emails from direct admin to PMG... From there it's sent out to whom ever the recipient is...
Now i'd like to know if it's possible to do one of the following 2 things...

1. I'd like to pass the mail from PMG to PostFix Server then back from PostFix Server to PMG in which case PMG then delivers the email as per normal...
2. I'd like to pass the mail from PMG to PostFix Server to then deliver the mail to the end recipient?

The catch is, this has to be done on a per domain basis. only selected domains need to go through this route while others can continue as normal from PMG to the end recipient...

Please let me know if it is possible with PMG, or what the best route to achieve this would be?

Side Note:
The purpose of the excercise isto change content in the email depending on data available in the database. So it would check mails to match against a DB, if it does match, change the content and then deliver it.
We can do that on the proxmox server aswell if it's safe to run PMG with altermime...

Any suggestions?
 
I would really try to go with option 2 in your case - sending a mail to one server and then back to the origin could easily end up in a mail loop - and you would need to configure postfix (on both systems) to route the mail differently based on some header information (which you would need to provide)

one further alternative would be to send the mail initially to the altermime postfix (for those domains that need it) and from there to PMG

for option 2. (PMG sending the mails for some domains to altermime and altermime forwarding them out) you can simply configure transports for those domains in PMG (GUI->Configuration->Mail Proxy->Transport) to point to the altermime postfix

if you need to modify the postfix configuration for PMG you need to go through the templating system:
https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html#pmgconfig_template_engine

We can do that on the proxmox server aswell if it's safe to run PMG with altermime...
Haven't tried it - and would not be covered by our support - but quite a few users do have some mail proxies and milters running on a PMG installation.

I hope this helps!
Let us know how it works out
 
I would really try to go with option 2 in your case - sending a mail to one server and then back to the origin could easily end up in a mail loop - and you would need to configure postfix (on both systems) to route the mail differently based on some header information (which you would need to provide)

one further alternative would be to send the mail initially to the altermime postfix (for those domains that need it) and from there to PMG

for option 2. (PMG sending the mails for some domains to altermime and altermime forwarding them out) you can simply configure transports for those domains in PMG (GUI->Configuration->Mail Proxy->Transport) to point to the altermime postfix

if you need to modify the postfix configuration for PMG you need to go through the templating system:
https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html#pmgconfig_template_engine


Haven't tried it - and would not be covered by our support - but quite a few users do have some mail proxies and milters running on a PMG installation.

I hope this helps!
Let us know how it works out
Correct me if I am wrong though, but the transport is for inbound emails?
I am looking to forward outbound mails through another host which will modify the mail, not the inbound mail...
 
Correct me if I am wrong though, but the transport is for inbound emails?
the transports sets the transport_maps parameter of postfix irrespective of the direction the mail arrives in
(iow it is for in and for outbound mail)

I hope this helps!
 
the transports sets the transport_maps parameter of postfix irrespective of the direction the mail arrives in
(iow it is for in and for outbound mail)

I hope this helps!
How do I do that in the interface though?

From what I can see, I can route inbound emails, I am not sure how to route 1 domain in PMG to a seperate smtp gateway?
 
create a transport entry for this domain pointing to the smtp gateway
But there's already a transport for it to deliver inbound emails to our direct admin server?
How do I differentiate between in and outbound mail so it routes inbound email to 1 server for the domain, and outbound email to another?
 
See what you mean - the transport_maps is for mail _to_ one particular domain (not _from_ one)

take a look at the sender_dependent_relayhost_maps parameter of postfix (have no experience myself with this, but should be what you are looking for):
http://www.postfix.org/postconf.5.html#sender_dependent_relayhost_maps
http://www.postfix.org/postconf.5.html#relayhost

I hope this helps!
I have no idea what I am looking for in the doc's... Haven't done something like this before...
Can you maybe elaborate more or less what I should be looking for?
 
See what you mean - the transport_maps is for mail _to_ one particular domain (not _from_ one)

take a look at the sender_dependent_relayhost_maps parameter of postfix (have no experience myself with this, but should be what you are looking for):
http://www.postfix.org/postconf.5.html#sender_dependent_relayhost_maps
http://www.postfix.org/postconf.5.html#relayhost

I hope this helps!

I did find this: https://www.howtoforge.com/community/threads/solved-postfix-sender-dependent-relay.73344/
Which makes sense, but brings into question how proxmox will deal with it. I can't imagine commenting out the transport maps is a good idea?...
 
As said - never had the use-case for this and thus have never tested something like this, but why don't you just try to set the value and test it?

from http://www.postfix.org/transport.5.html
I would guess that the setting of sender_dependent_relayhost_maps is used unless you have an explicit transport_maps entry for a destination domain (which you would only have for an internal domain) - so this should work for most things - not for mails from one of the altermime domains to one of your other internal domains
 
As said - never had the use-case for this and thus have never tested something like this, but why don't you just try to set the value and test it?

from http://www.postfix.org/transport.5.html
I would guess that the setting of sender_dependent_relayhost_maps is used unless you have an explicit transport_maps entry for a destination domain (which you would only have for an internal domain) - so this should work for most things - not for mails from one of the altermime domains to one of your other internal domains
Ok so I tested it and it seems as soon as the sender dependent default is enabled. All other mail routing is stopped...So I am sure I am missing something...

Looking for more detailed docs still at the moment though to find a solution...
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!