Re: [exim] Exim re-writing addresses.

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Alan Smith
CC: exim-users
Subject: Re: [exim] Exim re-writing addresses.
On Fri, 7 Jan 2005, Alan Smith wrote:

> When mail comes in to 'john@???' it gets re-written to
> 'john@???' and forwarded through, where server1.domain.com is
> the internal mail server. This all works fine in our current mail set up,
> but we have just bought a spam filter from here
> 'http://www.barracudanetworks.com/'. The barracuda box doesn't seem to like
> the re-written addresses and just gets stuck in a loop. What I want to know
> is, what type of re-write rules do I need to be looking at to get exim to
> filter the mail based on the aliases file, but forward on without re-writing
> addresses? If possible, can Exim filter based on the aliases file and then
> just forward all mail via SMTP to a specific IP?


It sounds as though you are using rewriting to do routing, which is not
the recommended way of doing it in Exim. Routing is best done by
routers (surprise, surprise). You don't need rewriting rules to arrange
routing (Exim is not Sendmail :-).

As I understand it, you have mail arriving for john@??? on your
mail gateway box, and you want to forward it to an internal box without
changing anything. That is easy. Just put this as your first router:

inrouter:
driver = manualroute
domains = domain.com
route_list = * server1.domain.com

That will automatically send all mail for anthing@??? to server1.
If you want to be more selective, you can do so by using files or
databases to list the local parts that you want forwarded (or not
forwarded). In fact you probably want to do this if you are using the
routers for recipient verification so that bad addresses do not verify.
So, let's suppose you only have a few (dozen) users. Put all their names
in a file, one per line:

alan
john
peter
....

and call this file /etc/mailusers. Then you can modify the above router
to be something like this:

inrouter:
driver = manualroute
domains = domain.com
local_parts = lsearch;/etc/mailusers
route_list = * server1.domain.com

Now it will forward only the local parts that it recognized. However, we
must think about what happens for unrecognized local parts. They will be
passed to the next router. You probably want to bounce them. You can do
this explicitly with this router:

bounce_unknown:
driver = redirect
domains = domain.com
data = :fail: $local_part is not known at $domain

This is all off the top of my head and untested. There are many
variations on these themes; you might like to fiddle around to see which
suits you best.

Note that you can test routing configurations using -bt.

-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book