This is a discussion on redirect all emails from an adress to another server within the mailing.postfix.users forums, part of the Mail Servers and Related category; Hello, When I receive an email, if the user "TO" is in my LDAP directory then send email ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
When I receive an email, if the user "TO" is in my LDAP directory then send email correctly if the user is not in the LDAP directory but the domain is ok, forward it to another server with another IP. Thanks |
|
|||
|
benjamin.sebbah@gmail.com wrote:
> Hello, > > When I receive an email, > if the user "TO" is in my LDAP directory then send email correctly > if the user is not in the LDAP directory but the domain is ok, forward > it to another server with another IP. > > Thanks I haven't tested this scenario, but I think you could do it like this: In the transports configuration, perform an LDAP lookup for existing email addresses, and if they exist, use the "local:" transport. If not, route that domain's traffic to the other server. --< main.cf >-- transport_maps = ldap:/etc/postfix/ldap.cf, proxy:hash:/etc/postfix/transport --< transport >-- @mydomain.com smtp:[server2.mydomain.com] --< ldap.cf >-- bind = no domain = mydomain.com timeout = 120 search_base = o=MyLDAPdatabaseNAME server_host = ldap://ldap.mydomain.com server_port = 389 query_filter = (mail=%s) result_attribute = "local:" -- Greg |
|
|||
|
Thanks Greg for your answer
Unfortunately before testing this solution I'd like to understand something without the LDAP directory: if I send an email to smtp1.mydomain.com and the user is not known in any base then transfer (I should say transport?) it to smtp2.mydomain.com I understand it should be done with "transport" but I just can't succeed to do it with the same domain. If you have any idea... Ben |
|
|||
|
benjamin.sebbah@gmail.com wrote:
> Thanks Greg for your answer > > Unfortunately before testing this solution I'd like to understand > something without the LDAP directory: > if I send an email to smtp1.mydomain.com and the user is not known in > any base then transfer (I should say transport?) it to > smtp2.mydomain.com > I understand it should be done with "transport" but I just can't > succeed to do it with the same domain. > > If you have any idea... > > Ben > If I understand correctly, you want to test manually before using an LDAP solution? You could put some email addresses in the /etc/postfix/transport file. This assumes using "transport_maps = hash:/etc/postfix/transport", or equivalent in the main.cf file: ---< /etc/postfix/transport >--- # Local users user1@mydomain.com local: user2@mydomain.com local: # Users on other machine user3@mydomain.com smtp:[smtp2.mydomain.com] user4@mydomain.com smtp:[smtp2.mydomain.com] # Or else use a default for all other users not listed above mydomain.com smtp:[smtp2.mydomain.com] -- Greg |
|
|||
|
Actually I found something very interesting:
--< main.cf >-- fallback_transport = smtp:server2.mydomain.com Local users stay on server1 and the others move on to server2 which is absolutely what I wanted to do. I didn't test it with LDAP yet but I think it will not be a problem. Ben |
|
|||
|
This solution doesn't work when mailbox_transport = cyrus is in
main.cf If anybody has an idea, because I can't use Greg's solution as I can't manually add every user in /etc/postfix/transport or maybe there is a method to import them automatically? Thanks Ben |