Hello everyone,
I am maintaining a simple list server for an organisation with many email
address lists, based on a SQL backend. The idea is that members (of database
list name 'relay') can send email to <listname>@mydomain.com, and exim will
relay this email to the members of group <listname> . The router listing is
below.
An email to a listname works fine, but I see some strange behaviour when an
email is sent to 2 listnames, eg
from: valid_sender@???
to: list1@???, list2@???
The result is that all users in list1 and list2 receive the relayed email
twice. The "duplicate" emails have different mail ids. For the example, assume
that name1 and name2 are on list1, and name3 and name4 are on list2.
extract from log (date/times omitted)
1FmKnk-0007Es-OL <= valid_sender@???
.. some local deliveries omitted
1FmKnl-0007Es-Q6 <= valid_sender@???
.. some local deliveries omitted
1FmKnk-0007Es-OL => name1@??? <list1@???>
1FmKnk-0007Es-OL -> name2@??? <list1@???>
1FmKnk-0007Es-OL => name3@??? <list2@???>
1FmKnk-0007Es-OL -> name4@??? <list2@???>
1FmKnk-0007Es-OL Completed
1FmKnl-0007Es-Q6 => name1@??? <list1@???>
1FmKnl-0007Es-Q6 -> name2@??? <list1@???>
1FmKnl-0007Es-Q6 => name3@??? <list2@???>
1FmKnl-0007Es-Q6 -> name4@??? <list2@???>
1FmKnl-0007Es-Q6 Completed
Some things I notice but don't understand: why the '=>' after the correct
members of list1 are processed. It's also possible that sometimes some of the
redirected emails can't be delivered (eg wrong addr, or mailbox full, etc)
Any help would be much appreciated.
Environment: exim 4.50 (debian stable). The database is postgres.
Router Listing =============
db_lookup:
# preconditions
# domain must be for on of ours
domains=+local_domains
# local part must be for a valid email group name
local_parts=${lookup pgsql{select groupname from emailgroup where
groupname='$local_part'}}
# router accept conditions
# sender must be in this list
senders=${lookup pgsql{select addresses from emailgrp where grp='relay' and
lower(addresses)='${lc:$sender_address}'}}
# header X-nbc-mailer must not be set
condition=!def:h_X-nbc-mailer:
# if all preconditions and conditions pass, do the following
driver=redirect
allow_fail
# add the following header to the redirected mail
headers_add=X-nbc-mailer:${primary_hostname} processing group ${local_part}
# this data (list of names) is passed to the redirect driver
data = ${sg{\
${lookup pgsql \
{select addresses from emailgrp where grp='$local_part'}\
}\
} {\\n}{, }}