Re: [exim] relay all mail to 1 address and NOT real destinat…

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Phil Pennock
Datum:  
To: Scott Mueller
CC: exim-users
Betreff: Re: [exim] relay all mail to 1 address and NOT real destinations
On 2008-07-05 at 19:38 -0700, Scott Mueller wrote:
> I'm trying to setup a development/staging environment for our web
> application such that all emails are routed to 1 particular email address
> instead of their real destination email addresses. This allows us to make
> sure the emails were constructed properly, count them for testing the
> correct number sent, etc.
>
> How can I do this with exim?


Have a first Router which is a redirect Router, which redirects all
email to one address. Either rely upon loop detection, so that the this
router is only used twice and skipped the third time [*] or put in a
safety check. It's used twice; first to redirect A -> Catchall, then
Catchall -> Catchall, then the third time the Router has already handled
Catchall as input. The "condition" here avoids this

capture_all:
driver = redirect
data = my-capture@???
condition = ${if !eq{$local_part@$domain}{my-capture@???}}

The remaining Routers will then route that mail "normally".

More elegantly, to keep the same mail configuration on all hosts and
change the behaviour by some outside file, you'd make this dependent
upon the existence of a file. Eg, something like:

devel_capture_all:
  driver = redirect
  data = my-capture@???
  condition = ${if and{\
                   {exists{/etc/STAGING}}\
                   {!eq{$local_part@$domain}{my-capture@???}}\
           }}


You can replace:
{exists{/etc/STAGING}}\
with:
{or{{exists{/etc/STAGING}}{exists{/etc/TESTING}}}}\
too.

Another approach would be to wrap the block in .ifdef/.endif and then
start exim with a -D flag to define the relevant macro from the .ifdef
line, and only do that on staging boxes. This will only work if all
mail is submitted by smtp or you configure exim to queue_only, so that a
queue-runner started by the daemon (which has the flag) will in turn
have the cmdline flag set when running.

Regards,
-Phil