Two mail servers

I did not find how you can proxy mail to two different mail servers. Is it possible to do this?
Example: mail1@example.com
belongs to server1
and mail2@examle.com belongs to server2
server1 192.168.0.10
server2 192.168.10.20
server1 postfix
server2 exchange

I just responded in the other thread, no, it’s not possibile with haproxy:

Haproxy is not the right tool for this job.

You need an SMTP relay (smarthost) capable of determining which host a destination mailbox resides on. If you had two such relays, you could use haproxy to load balance them, I suppose.

I tried a lot of options, unfortunately none of them works.

Unless you mean you’ve tried a lot of haproxy options–in which case, it can’t work–you need to be looking at changing the configuration on each of your existing mail servers so each is aware of which mailboxes reside on the other server. Look into Exchange “shared domain” documentation, for example.
You’ll need similar functionality in Postfix. A shared source of this information (such as A/D or LDAP) will lighten the administrative burden considerably, but would require significant complexity to set up.
Either way, this is completely out-of-scope for HAProxy and you should be looking for help for your MTAs in the usual places, or engaging a consultant with expertise in hybrid e-mail environments.

Большое спасибо, именно о диспетчере каталогов я и подумал.

Попробую организовать центральное управление пользователями на
основе OpenLDAP.

Еще раз большое спасибо.

Thank you very much.

I am in the process of moving and unfortunately the ISP that services the new location will only provide/rent 1 STATIC IP address.

Currently I have a block of 5 IP address are utilized for pet projects.

My pfSense box is connected to a semi-managed smart switch and to that is connected my VM Host with multiple NIC cards installed.

The VM Host is running several VMs each doing specific tasks. VM #1 Web, VM #2 Mail, VM #3 NAS, etc…

Would HAProxy work for the following scenario.

www.somedomainname1.com <---> pfSense/HA Proxy <---> 192.168.10.2 / NIC 1 / VM 1

www.somedomainname2.com <---> pfSense/HA Proxy <---> 192.168.20.2 / NIC 2 / VM 2

imap(smtp).somedomainname1.com <---> pfSense/HA Proxy <---> 192.168.30.2 / NIC 3 / VM 3
imap(smtp).somedomainname2.com <---> pfSense/HA Proxy <---> 192.168.30.2 / NIC 3 / VM 3

imap(smtp).somedomainname3.com <---> pfSense/HA Proxy <---> 192.168.40.2 / NIC 4 / VM 4

No, this is not possible, for the reasons mentioned here:

Thanks for the reply.

I want to be clear I am not looking for the level of granularity the OP was looking for of routing based on a users email address but rather the email domain.

For example:

imap(smtp).somedomainname1.com <---> pfSense/HA Proxy <---> 192.168.30.2 / NIC 3 / VM 3
imap(smtp).somedomainname2.com <---> pfSense/HA Proxy <---> 192.168.30.2 / NIC 3 / VM 3

imap(smtp).somedomainname3.com <---> pfSense/HA Proxy <---> 192.168.40.2 / NIC 4 / VM 4

I understand, but neither SMTP nor POP3 nor IMAP indicate the domain name in the first packet, which would be required to content switch it to different backend servers.

Only in the case of implicit SSL can we actually use the hostname from the SSL client_hello SNI field for load-balancing decisions, which I very much doubt will address all your use-cases.