RE: [exim] forward an deliver to mailbox at the same time

Pàgina inicial
Delete this message
Reply to this message
Autor: Peter Savitch
Data:  
A: Maykel Moya
CC: exim-users
Assumpte: RE: [exim] forward an deliver to mailbox at the same time
Hi.

> One solution I'd seen is to put the same address in a .forward file:
> user foo@??? wants to get the messages and forward it to
> bar@???
>
> ~foo/.forward
> -------------
> foo
> bar@???


In this case Exim's intrinsic loop detection and avoidance will just
skip the router that produced loop. The adrress `foo' does make loop, so
the userforward router will be skipped, probably giving `Unroutable
address' response.

> That solution is not suitable for me in an environment where are tons

of
> virtual addresses.
>
> I suppose the same goal could be achieved with a .procmailrc. Now, my
> question, it is possible to achieved the goal at a exim level.
>
> Having users in a mysql db, a field expands to a redirect data, I

would
> like to have a boolean value which stats if the message should be
> locally delivered beside forwarded.


Sure it's possible at Exim level. The `unseen' generic router option is
your choice. Make two adjacent routers, one `driver = redirect' and one
`driver = manualroute', order does not actually matter.

The idea follows. The first router (say redirect) has `unseen' option
set to expandable condition (based on your MySQL data) that returns
`true' if the message should be delivered local. When this yields true,
address replicated and the processing continues with the following
(adjacent) router (say, `driver = manualroute').

If the address should be delivered only locally, the former router
(redirect) will just decline and the control passes to the latter router
(manualroute), that is, no check for `unseen' ever made. But: you must
make the routers consistent, that is, if address is replicated in the
former router, the latter router must never decline. You'll receive
unpredictable results else.

Play with the $address_data, but beware: you can not check (read) the
$address_data in the pre-condition of the same router that sets (writes)
it.
Pre-conditions are `domains', `local_parts', `condition' - they can't.
Both redirection `data' and `unseen' can use $address_data. So, make
redirect router fill the $address_data and use it's value in `data'
(empty results are okay - the router declines). The next `manualroute'
router can use $address_data everywhere, including pre-conditions,
because $address_data is set earlier, in the preceding router.

Is that clear?

You must make appropriate DB schema with a clear semantics: both
strategies are looking like options: local and redirect are
not-mutually-exclusive.
You could even make the third option (envelope-preserving
forward-to-host), if you are experienced enough with Exim.