Re: [exim] Different target hosts and types for a Exim gatew…

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: exim.ml@riotm.co.uk
Dátum:  
CC: exim-users
Tárgy: Re: [exim] Different target hosts and types for a Exim gateway
On Sun, 2010-04-18 at 15:16 -0700, Todd Lyons wrote:
> On Sat, Apr 17, 2010 at 4:22 PM, Ted Cooper <eximX0902w@???> wrote:
> > On Fri, 2010-04-16 at 11:00 +0100, exim.ml@??? wrote:
> >> Where I'm stumped is how and where I extract the destination host type
> >> and have Exim resolve it (host/mx) if necessary and populate a
> >> variable/data field to feed to the transport. It's probably really
> >> simple, but I'm confusing myself and having some trouble getting this
> >> 'clear' as a logical problem in my head.
> >
> > Use SQL to seperate the domains into categories for each type? ie split
> > your mysql_localbox into mysql_forward_mx etc and then use the
> > "domains=" line with an SQL query to target the right router.
> >
> > eg
> > LOOKUP_FWDDOMAIN=SELECT domainname FROM client_domains WHERE domainname
> > = '${mysql_quote:$domain}' AND dtype = 'forward'
> > forwardomains:
> > driver = manualroute
> > domains = ${lookup mysql{LOOKUP_FWDDOMAIN}{$value}}
> > local_parts = ${lookup mysql{LOOKUP_ALL_USERS}{$value}}
> > route_data = ${lookup mysql{LOOKUP_ROUTEDATA}{$value}}
> > transport = remote_smtp
>
> The above is typically the way that I do things as well, but in this
> case, this seems a bit inefficient because it's doing 3 lookups for
> this router. If the op could do a single lookup that returns all of
> the data needed, he can just ${extract} to get the individual values
> from the returned data. Reading the docs, it seems simple, but then
> again I've never done it that way (because I've not yet had the need
> to do it that way.)
>
> Just thought I would throw out that, if it can be constructed, a
> single lookup could be a bit more efficient and result in a little bit
> less load. Emphasis on "if it can be constructed". You might just
> make it suitably complicated that it lessens its troubleshooting
> ability and also one or more of these lookups might be used elsewhere,
> in the ACL's for example, and caching means that the lookup may have
> already been done and so doing another, more complicated lookup makes
> it worse and not better.
>
> ...before sending I always read and reread my post.  I'm basically
> saying "you could do it this way unless it doesn't work for you".  I
> almost didn't send it...
> -- 
> Regards...      Todd
> I seek the truth...it is only persistence in self-delusion and
> ignorance that does harm.  -- Marcus Aurealius

>


OK, I'm making headway. I am now able to actively route and transport
recipients that have their endpoint on the local server, and relay
recipients where the destination is a hostname lookup using these
routers:

mysql_localbox:
driver          = accept
domains         = +hosted_domains
condition       = ${lookup mysql{SELECT email FROM mailusers WHERE
usertype=0 AND inbound=1 AND active=1 AND email='${quote_mysql:
$local_part}@${quote_mysql:$domain}'}}
local_part_suffix       = +*
local_part_suffix_optional
transport               = local_mysql_delivery
no_more


relay_to_hostname:
driver          = manualroute
route_data      = ${lookup mysql{SELECT relay_destination FROM mailusers
WHERE usertype=1 AND inbound=1 AND relay_type=1 AND active=1 AND
email='${quote_mysql:$local_part}@${quote_mysql:$domain}'}}
transport = transport_to_hostname
host_find_failed = defer


....
transport_to_hostname:
driver = smtp
....

Now the bit that has me stumped is how do I handle the situation for
recipients where I need to lookup the MX for their domain and for
literal IP addresses instead of hosts?


Looking at the literal IP issue first, I can't find any options on how
to route those. The 'route_data' option only appears to allow a host
list, not literal IP's. I could use any help on this as my reading of
docs and googling is not helping much here.

As far as MX lookups are concerned, a couple of possible options appear
in the docs, but I'm not sure if they are graceful, wasteful or plain
illegal.

I first found 'lookuphost' but that appears to only be in the docs for
version 3. (That is a 'search' for it in
http://exim.org/exim-html-4.50/doc/html/spec_toc.html fails)

Perhaps I can do something like:

relay_to_mx_lookup:
driver          = manualroute
#there will have to be a condition here - spending a lookup if legal


condition = ${lookup mysql{SELECT relay_destination FROM mailusers WHERE
usertype=1 AND inbound=1 AND relay_type=1 AND active=1 AND
email='${quote_mysql:$local_part}@${quote_mysql:$domain}'}}

#assuming the result of the above is not available to us without an
#explicit assignment - this may be a wrong assumption
#it also spends a repeat lookup (which may be cached??)

somevariable = ${lookup mysql{SELECT relay_destination FROM mailusers
WHERE usertype=1 AND inbound=1 AND relay_type=1 AND active=1 AND
email='${quote_mysql:$local_part}@${quote_mysql:$domain}'}}

#do a DNS lookup on the result.... is this legal????
route_data      = ${lookup dnsdb{mx=somevariable}{$value}fail}
transport = transport_to_mx
host_find_failed = defer


But I'm not sure about that?

The dnslookup driver lookup would be ideal, but the complication is it
would need to only apply to certain recipients - so a condition would
need to limit it. To make it more dark the result of that condition
lookup would need to be value that is actually looked up in dns for an
mx record(s).


To get something clear in my head, can I use a condition in all routers?
Is that allowed? If that condition is formed from a MySQL lookup, is the
result of that lookup assigned to some process variable so I can make
use of it?