Relaying mails for recipients which are not known

Hello,

I have setup a Kopano server like described in the Administration Manual. We are using Active Directory for user management and Postfix for mail delivery.

The Postfix configuration looks like:

virtual_mailbox_domains = example.com
virtual_mailbox_maps = ldap:/etc/postfix/ldap-users.cf
virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf, ldap:/etc/postfix/ldap-groups.cf, ldap:/etc/postfix/ldap-groups-expand.cf
virtual_transport = lmtp:127.0.0.1:2003

Now we have some users with the same domain(virtual_mailbox_domains) which are not maintained by Kopano but a other mail system on another place.

My goal:

I want to to relay all mails to these users to a specific host. Does anybody know how to setup postfix for that purpose.

Greetings,

FoxholeCommander

Hello @FoxholeCommander ,

such a configuration can be achieved with transport maps in Postfix (either queried from ldap/ad or with a static map). You basically have to map the external addresses to the external mailserver.

Hello @fbartels

do you mean with the parameter transport_maps in main.cf? I tried it on my test environment yesterday but postfix is ignoring that although the parameter is set in the main.cf

Greetings,

Michael

Hi @FoxholeCommander,

what exactly did you set in your main.cf? Because its more than just a one line change.

Something like the following should do the trick for you:

Add transport_maps = hash:/etc/postfix/transport to you main.cf and create the file with the following content:

external-user1@my-domain.com smtp:[external.mx.de]
external-user2@my-domain.com smtp:[external.mx.de]

With every modification of the transport file you have to call postmap /etc/postfix/transport.

Hello FBartels,

in my config it wasn`t that simple and the transport_maps parameter was just a part of the solution. Additionally I had to make a hash table in the config line virtual_mailbox_maps. So now it looks like:

virtual_mailbox_maps = ldap:/…, has:/…

Greetings,

FoxholeCommander

Hey,
I’ve a similar problem: Many users are maintained by our local Kopano server, but as many users will be maintained by an external mailserver. I don’t know all of the external users, but all of my local users are listed in ldap.
How can I configure this?

My setup: the local Kopano server maintains three domains: example1.at, example2.at and example3.atexample3.at must be splited into local users (from ldap) and all other unknown users to external

Fortunately, the MX record for example3.at points to the external server, I use fetchmail to get the mails for my local users.
I removed example3.at from virtual_mailbox_domains in my postifx config, so every mail to an user *@example3.at will be delieverd to the external server. Is it possible to filter the local users?

virtual_mailbox_domains = example1.at, example2.at
#,example3.at
virtual_mailbox_maps = ldap:/etc/postfix/ldap-users.cf,hash:/etc/postfix/virtual/addresses
virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf,hash:/etc/postfix/virtual/addresses
virtual_transport = lmtp:127.0.0.1:2003
transport_maps = ldap:/etc/postfix/ldap-transport.cf,hash:/etc/postfix/transport

This does not work: /etc/postfix/ldap-transport.cf

server_host = localhost 
search_base = ou=Users,dc=customerxyz,dc=local
version = 3
scope = sub
query_filter = (&(mail=%s)(kopanoAliases=%s)) 
result_attribute = mail
result_format = kopano

and /etc/postfix/transport

example3.at                     smtp:bsmtp.a1.net:587