redirect all emails from an adress to another server

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 ...


Go Back   Usenet Forums > Mail Servers and Related > mailing.postfix.users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2006
benjamin.sebbah@gmail.com
 
Posts: n/a
Default redirect all emails from an adress to another server

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

Reply With Quote
  #2 (permalink)  
Old 03-01-2006
benjamin.sebbah@gmail.com
 
Posts: n/a
Default Re: redirect all emails from an adress to another server

I forgot to say that I am using Postfix 2 with cyrus
I'm thinking of doing a catch-all user but I don't know how to really
do it

Reply With Quote
  #3 (permalink)  
Old 03-02-2006
Greg Hackney
 
Posts: n/a
Default Re: redirect all emails from an adress to another server

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




Reply With Quote
  #4 (permalink)  
Old 03-03-2006
benjamin.sebbah@gmail.com
 
Posts: n/a
Default Re: redirect all emails from an adress to another server

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

Reply With Quote
  #5 (permalink)  
Old 03-03-2006
Greg Hackney
 
Posts: n/a
Default Re: redirect all emails from an adress to another server

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



Reply With Quote
  #6 (permalink)  
Old 03-05-2006
benjamin.sebbah@gmail.com
 
Posts: n/a
Default Re: redirect all emails from an adress to another server

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

Reply With Quote
  #7 (permalink)  
Old 03-13-2006
benjamin.sebbah@gmail.com
 
Posts: n/a
Default Re: redirect all emails from an adress to another server

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:16 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0