[exim] Different target hosts and types for a Exim gateway

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: exim.ml@riotm.co.uk
Fecha:  
A: exim-users
Asunto: [exim] Different target hosts and types for a Exim gateway
I'm looking for a nudge in the right direction regarding my
'experiments' with Exim. I'm having to fit this in around other things
so my learning and progress have not been as good as I would like up to
now, but I'm dogmatic.

I've built my Exim by hand on a Cent5 Virtualbox with MySQL support. My
long term aim is to add 'features' to this and then deploy it on real
hardware to replace a few Postfix servers (It's my patriotic duty!). I
have Exim up and running and delivering 'virtual' users to local
mailboxes with no issue after looking up the presence of the recipient
in a MySQL database.

The aim is to have the system offer this (some of this I have working);

Handle mail for multiple domains - but with quirks.
Some domains will be entirely hosted on the server with delivery to a
local maildir_format directory. This I have working.

Some domains will be entirely hosted elsewhere and will be relayed to.
This I have working in part

Some domains will be mixed with some users hosted on the server, and
others relayed onwards. This I have working in part

I've figured I can easily work out which recipient is which using some
simple flags in the database and building my routers like this:

mysql_localbox:
driver          = accept
domains         = +local_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


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


and this works fine with the appropriate transports:
local_mysql_delivery:
driver  = appendfile
directory = /var/spool/mail/${domain}/${local_part}/
maildir_format
delivery_date_add
envelope_to_add
return_path_add
user    = vmail
group   = vmail
mode    = 0660


mysql_delivery_relay_to_ip:
driver = smtp
hosts = ip.add.of.target
hosts_override

But the complication - and my area of confusion - is dealing with relay
hosts that may have one of three destination scenarios. Deliver to a
destination IP, deliver to a destination hostname (a DNS lookup needed),
or deliver to an mx for a domain (dns lookup required) for the domain
(aware of the potential issues here with loops). This is indicated by a
type flag in the database and an associated data field holding either a
ip, hostname or domain depending on the flag value (0,1,2).

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.

My approach may even be over-complicated or wrong in dealing with the
scenario, so I'm very open to learning or pointers.