Re: [exim] Selective routing/delivery per user

Top Page
Delete this message
Reply to this message
Author: Darren Honeyball
Date:  
To: exim-users @ exim. org
Subject: Re: [exim] Selective routing/delivery per user
On 30/5/07 17:42, Ted Cooper wrote:
> Darren Honeyball wrote:
>
>> Hi,
>>
>> I have a requirement to be able to somehow set a flag (flat file or
>> database) and deliver mail to another server on a per user basis
>> depending on the state of the flag. Both servers handle the same domain
>> (e.g. partner.company.com).
>>
>> So, a mail comes into server A for user1@??? - no flag
>> is set so its delivered locally on server A. Another mail comes in for
>> user2@??? but this time the flag is set, so I'd like to
>> deliver this to server B for local delivery there.
>>
>> Any pointers/tips? I've found various examples, none of which seem to
>> work how I'd like when testing them.
>>
>
> If you take the flat file approach, you could put in a manual route with
> conditions on it.
>
> Flat file looking like:
> user1
> user2
> user4
>
> Then in routers use something like this. Keep in mind that the order of
> routers is very important - this is in fact the key to how this works.
> In my setup, this would go after the alias routing but before any local
> deliveries.
>
> otherserver:
> driver = manualroute
> domains = +local_domains
> local_parts = lsearch;/path/to/flat/file/above
> transport = remote_smtp
> route_list = * IP.OF.OTHER.SERVER
>
> [ .. other routers .. ]
>
> localuser:
> .. your normal localuser type thing
>
> You can replace the lsearch/flatfile with pretty much any query method
> you can think of.
> This is will route all message destined for the other server to that
> server and any that didn't match would fall through to the remaining
> routers.
>


Excellent, thanks - That gave me the clue I needed - I've now got it
working with mysql:

conditional_forward:
        driver          = manualroute
        domains         = +local_domains
        local_parts     = ${lookup mysql{SELECT user_localpart FROM
exim_forward \
                                WHERE user_localpart =
'${quote_mysql:$local_part}' \
                                AND forward = '1'}}
        transport       = remote_smtp
        route_list      = * remote.server1:remote.server2


D