[Exim] Success!! Autoreply, aliasing, AND local delivery fr…

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Ericb
Data:  
Para: exim-users
Temas antigos: Re: [Exim] bogofilter - Exim filter help needed
Asunto: [Exim] Success!! Autoreply, aliasing, AND local delivery from mysql DB!
Hi everyone,

After reading some suggestions and reverse engineering the output of the
config file conversion script, I was able to achieve my fully functional
exim.
Using a single authentication table and one entry per address, exim will
perform the following,
- appendfile to /var/mail/domain/user
- optionally forward to aliases
- cause an autoreply to be generated

This was accomplished somewhat unconventionally (read: hack) and I am
hoping one of you can suggest a better idea. I essentially have a big
query that constructs a string of comma separated email addresses using
CONCAT(). Each row in the auth table contains 3 flags, is_mbox,
is_alias, is_autoresp, and the SQL CASE & WHEN statements are used to
trap each possible combination....
- if is_mbox = yes, add the address to this string. Local delivery
router will process it. (A)
- if is_alias = yes, add the aliased addresses to the string. (B)
- if is_autoresp = yes, add the address userAUTORESPTAG@domain. (C)

Addresses in (A) and (B) will get routed normally. The address in (C)
don't really exist since they contain the extra text AUTORESPTAG, which
is kind of a flag, that only the autoreply router will catch, and if
is_autoresp=yes, does the autoreply. Works, but ugly. Why this mess?
Because the autoresponder and virtual_delivery routers uses
driver=accept, while alias uses driver=redirect, and I can't find the
way for the life of me to have a single message get processed by accept
AND redirect.

Below is the config. The first line is the query that does the process
explained above.

--------------------------------

# mysql server definition omitted

SICK_QUERY = SELECT CASE WHEN ( ( is_mbox = 'yes' ) AND ( is_alias =
'no' ) AND ( is_autoresp = 'no' ) ) then CONCAT( username, '@', domain )
WHEN ( ( is_mbox = 'no' ) AND ( is_alias = 'yes' ) AND ( is_autoresp =
'no' ) ) then alias WHEN ( ( is_mbox = 'yes' ) AND ( is_alias = 'yes' )
AND ( is_autoresp = 'no' ) ) then CONCAT( username, '@', domain, ' , ',
alias ) WHEN ( ( is_mbox = 'no' ) AND ( is_alias = 'no' ) AND (
is_autoresp = 'yes' ) ) then CONCAT( username, 'xxxautoresp@', domain )
WHEN ( ( is_mbox = 'yes' ) AND ( is_alias = 'no' ) AND ( is_autoresp =
'yes' ) ) then CONCAT( username, '@', domain, ' , ', username,
'xxxautoresp@', domain ) WHEN ( ( is_mbox = 'no' ) AND ( is_alias =
'yes' ) AND ( is_autoresp = 'yes' ) ) then CONCAT( alias, ' , ',
username, 'xxxautoresp@',domain ) WHEN ( ( is_mbox = 'yes' ) AND (
is_alias = 'yes' ) AND ( is_autoresp = 'yes' ) ) then CONCAT( username,
'@', domain, ' , ', alias, ' , ', username, 'xxxautoresp@', domain )
END FROM auth where ( is_mbox = 'yes' or is_alias = 'yes' or is_autoresp
= 'yes' )

QUERY_MBOX = ${lookup mysql {select concat(username,'@',domain) from
auth where is_mbox='yes' AND domain LIKE '${quote_mysql:$domain}' AND
username LIKE '${quote_mysql:$local_part}'}{$value}fail}
QUERY_ALIAS = ${lookup mysql {select alias from auth where
is_alias='yes' AND domain LIKE '${quote_mysql:$domain}' AND username
LIKE '${quote_mysql:$local_part}'}{$value}fail}
QUERY_AUTORESP = ${lookup mysql {select concat(username,
'xxxautoresp@', domain) from auth where is_autoresp='yes' AND domain
LIKE '${quote_mysql:$domain}' AND username LIKE
'${quote_mysql:$local_part}'}{$value}fail}

primary_hostname = summit-tech.ca
domainlist local_domains = "localhost:mysql;select distinctrow domain
from auth where domain='${quote_mysql:$domain}'"
domainlist relay_to_domains =
hostlist relay_from_hosts = localhost : 10.0.0.0/16 :
64.254.226.128/25 : 216.208.216.64/27 : 66.201.203.128/26
localpartlist local_parts_ok = ${lookup mysql{select username from auth
where domain='@'}{$value}fail}

acl_smtp_rcpt = acl_check_rcpt
qualify_domain = summit-tech.ca
# qualify_recipient =
allow_domain_literals
never_users = root
host_lookup = *
rfc1413_hosts = *
rfc1413_query_timeout = 0s
#rfc1413_query_timeout = 30s

# sender_unqualified_hosts =
# recipient_unqualified_hosts =

# percent_hack_domains =

ignore_bounce_errors_after = 2d
timeout_frozen_after = 7d

#                       ACL CONFIGURATION                            #


begin acl
acl_check_rcpt:
  accept  hosts = :
  deny    local_parts   = ^.*[@%!/|] : ^\\.
  accept local_parts    = +local_parts_ok
         domains        = +local_domains
          verify        = recipient
    deny    message       = rejected because $sender_host_address is in
a black list at $dnslist_domain\n$dnslist_text
            dnslists     = spamhaus.relays.osirusoft.com :
relays.ordb.org
  accept  domains       = +local_domains
          endpass
          message       = unknown user
          verify        = recipient
  accept  domains       = +relay_to_domains
          endpass
          message       = unrouteable address
          verify        = recipient
  accept  hosts         = +relay_from_hosts
  deny    message       = relay not permitted


######################################################################
#                      ROUTERS CONFIGURATION                         #
#               Specifies how addresses are handled                  #
######################################################################


begin routers
domain_literal:
driver = ipliteral
domains = ! +local_domains
transport = remote_smtp

dnslookup:
driver = dnslookup
domains = ! +local_domains
transport = remote_smtp
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
no_more

super_virtual:
driver = redirect
data = ${lookup mysql {SICK_QUERY AND domain LIKE
'${quote_mysql:$domain}' AND username LIKE
'${quote_mysql:$local_part}'}{$value}fail}

# stuff like postmaster, root, abuse, @ any local_domain
virtual_localpart_alias:
driver = redirect
data = ${lookup mysql {select alias from auth where
username='${quote_mysql:$local_part}' and domain='@' and
is_alias='yes'}{$value}fail}

# this catches the autoresp
user_vacation:
driver = accept
condition = ${if eq {} {${lookup mysql {SELECT domain, message FROM
auth WHERE is_autoresp='yes' and concat(username,"xxxautoresp") LIKE
'${quote_mysql:$local_part}' AND concat("",domain) LIKE
'${quote_mysql:$domain}'}}}{no}{yes}}
# retry_use_local_part # not sure if I need this ??
transport = address_reply

virtual:
driver = accept
domains = ${lookup mysql {SELECT DISTINCT domain FROM auth WHERE
domain LIKE '${quote_mysql:$domain}' AND username LIKE
'${quote_mysql:$local_part}' AND is_mbox='yes'}{$value}fail}
transport = virtual_delivery

localuser:
driver = accept
check_local_user
transport = local_delivery

no_more


######################################################################
#                      TRANSPORTS CONFIGURATION                      #
######################################################################


begin transports

remote_smtp:
driver = smtp

local_delivery:
driver = appendfile
file = /var/mail/$local_part
delivery_date_add
envelope_to_add
return_path_add

virtual_delivery:
driver = appendfile
file = /var/mail/${domain}/${local_part}
user = exim
group = exim
mode = 0660

address_pipe:
driver = pipe
return_output

address_file:
driver = appendfile
delivery_date_add
envelope_to_add
return_path_add

address_reply:
driver = autoreply
from = ${lookup mysql {select distinct sourceaddr from auth where
is_autoresp='yes' and domain like '${quote_mysql:$domain}' and
concat(username,'xxxautoresp') like
'${quote_mysql:$local_part}'}{$value}}
subject = ${lookup mysql {select distinct subject from auth where
is_autoresp='yes' and domain like '${quote_mysql:$domain}' and
concat(username,'xxxautoresp') like
'${quote_mysql:$local_part}'}{$value}}
text = ${lookup mysql {select distinct message from auth where
is_autoresp='yes' and domain like '${quote_mysql:$domain}' and
concat(username,'xxxautoresp') like
'${quote_mysql:$local_part}'}{$value}}
to = $sender_address


begin retry
*                      *           F,2h,15m; G,16h,1h,1.5; F,4d,6h
begin rewrite
begin authenticators


---------------