Sender-dependent relaying in Postfix

Hi there,

I am, I believe, trying to use the "sender-dependent" feature of Postfix to send messages from different senders via different routes:

  • If a message is from, I want it to be sent via
  • If a message is from anyone else, I want it to be directly delivered, as is the default right now on the server.

All sorts of documentation points to /etc/postfix/dependent, but nothing tells me the format of this file.

I have destination-dependent relaying working using /etc/postfix/transport, but I need to get sender-dependent relaying working. Thanks.


Closed (fixed)
Virtualmin version: 
Webmin version: 


Ilia's picture
Submitted by Ilia on Sun, 03/14/2021 - 05:23

Hi, Craig!

Thanks for contacting us.

Umm, this must be already setup by Virtualmin and you should be able to automatically make it work by enabling it on - Server Configuration ⇾ Email Settings page and its Send outgoing email for domain from IP option.

If you don't see such option on mentioned page, then simply run the following command to let Virtualmin configure it properly for you:

virtualmin-config-system -i=Postfix

Hi Ilia,

Thanks for your quick reply. However, I only do web hosting on Virtualmin; I use a different control panel for email on a discrete server. Therefore I have disabled just about every email-related feature in Virtualmin that I can find, and so I don't have that path available to me. However, of course, I still need the server to be able to send out emails generated by web apps.

So all of the email sent out by this server is generated by web apps except stuff generated by Virtualmin itself -- control panel notices mostly. I want the latter to go out via a relay server, and the junk generated by web apps to be delivered directly.



You can also configure sender-dependent mappings in Webmin, at Webmin -> Servers -> Postfix Mail Server -> Sender Dependent Transport Mapping.

Thanks Jamie. I did see that, but it too refers to the file at /etc/postfix/dependent, and only asks me to create maps. That takes me back to my original question, either the format of /etc/postfix/dependent or how to create maps.

Is this close to what I want to do?:

I did also find this referring to /etc/postfix/dependent, but it doesn't really seem connected to what I want to do:


That link, with some minor tweaks, was actually what I needed to do. It seems to work as I intended.

Ilia's picture
Submitted by Ilia on Mon, 03/15/2021 - 03:48

Thanks for letting know. I initially didn't think of that kind of application. Never had a need to use it before.

What is the practical application for such routes?

Hi Ilia,

It's a rather long and involved story. However, the fact is that any sane mail admin blocks our web server's IP address. Users still insist on sending the contact form emails (and other emails from web apps) to their Gmail accounts (and other email accounts that are not on our own mail server), and don't do anything to prevent bad submissions. (I can and should do more to block bad IP addresses, and do other things to prevent spam submissions, but this is a work in progress.)

However, because the web server's IP address is blocked, emails generated by Virtualmin for account creation, certificate renewals, etc. are also blocked. With the above technique they can be delivered via a relay server that we run, thereby getting through.


Ilia's picture
Submitted by Ilia on Mon, 03/15/2021 - 05:09

Thanks, Craig for shedding light on it.

Thanks Jamie. I'm surprised that result wasn't in my search results, but I suppose I didn't dig deep enough.

The first reply to that post does contain the format information I was looking for, but I did find it also at the link I posted. One of the replies links to , which is also pretty succinct and similar to the link I posted that helped me.

Thanks again. Appreciate the pointer.

Great! I suppose if this feature in Webmin was more used, we could update the UI to make it clearer what the format is.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.