I need some more complex mail routing in my organization, i'm using the
smbldap-tools and lam as LDAP management tools and both support the
(10-years-expired!) 'laser' draft:
http://www.sendmail.org/m4/laser.txt
looking around seems that still there's no better LDAP schema, so...
i'm keeping that.
I've implemented roughly all the draft (really: with very loose
checks...), but i've some trouble to write the condition form
'mailHost'.
Some background. I've a domain (say 'pp.lnf.it') and two mail server:
mail.pp.lnf.it (the ''default one'') and mail.ud.lnf.it.
I need to do a thing like: ''deliver every mail from pp.lnf.it domain
to mail.pp.lnf.it server, apart some users that have the mailHost
attribute set to another server (indeed, mail.ud.lnf.it).
I've setup theee variables:
LOCAL_MAILHOST_NAME = mail.ud.lnf.it
The name of the ''current'' server, eg if the mailHost
attribute are equal to LOCAL_MAILHOST_NAME, the email have to
be delivered locally.
DEFAULT_MAILHOST_NAME = mail.pp.lnf.it
I don't want to set explicitly the mailHost attribute in LDAP
for every user, so this is is a ''default'' value to use when
mailHost attribue are empty (the primary server).
LOCAL_MAILHOST_LDAP_ROUTE_QUERY = ldaps:///ou=People,dc=pp,dc=lnf,dc=it?mailHost?one?(uid=$local_part)
The actual query
Then i've write this router (based on the idea from
http://www.exim.org/lurker/message/20110606.205437.60db08af.en.html):
.ifdef LOCAL_MAILHOST_NAME
user_mailhost_redirect:
debug_print = "R: user_mailhost_redirect for $local_part@$domain"
driver = manualroute
domains = +local_domains
route_data = ${if !eq{\
${if eq{${lookup ldap {LOCAL_MAILHOST_LDAP_ROUTE_QUERY}}}{}\
{DEFAULT_MAILHOST_NAME}\
{${lookup ldap {LOCAL_MAILHOST_LDAP_ROUTE_QUERY}}}}\
}{LOCAL_MAILHOST_NAME}{\
${if eq{${lookup ldap {LOCAL_MAILHOST_LDAP_ROUTE_QUERY}}}{}\
{DEFAULT_MAILHOST_NAME}\
{${lookup ldap {LOCAL_MAILHOST_LDAP_ROUTE_QUERY}}}}\
}{}}
transport = remote_smtp
.endif
And, i'm very proud, works.
But... ok that query are cached, but doing 4 times the same lookup on a
router is the right thing?
Again, i've read and test that if route_data are empty, the router are
skipped; but there's a better way to ''skip'' this router, so again
better condition writing?
Also, if the destination server (in this example, mail.pp.lnf.it) are
down, unreachable or generically ''on error'', what this router will
do?
Many thanks.
--
È come se Mendeleev quando ha scoperto gli elementi, il giorno che ha
scoperto l'ossigeno avesse detto: "benissimo, ho scoperto l'ossigeno, chi
respira mi paga una royalty"... chi respira paga, pensa a Genova che
casino, morivano tutti in apnea. (Beppe Grillo)