[exim] Mysql matching of $defaultdomain as well as $allvirtu…

Página Principal
Apagar esta mensagem
Responder a esta mensagem
Autor: Ernie Dunbar
Data:  
Para: exim-users
Assunto: [exim] Mysql matching of $defaultdomain as well as $allvirtualdomains
I'm an Exim newbie who's tooled around with it in Debian a bit, but now
I'm building a real mail server that will host virtual domains. We're
switching over from a qmail installation that allows most of our customers
to log in with their username only, while customers who have domain name
hosting log in with their full e-mail address.

I've started by following the directions at
http://struction.de/projects/HOWTO_VirtualMail_Exim-MySQL-Spamassassin-ClamAV-Dovecot/index
(with the exception of using Debian and tweaking things a bit) and have it
working to the point where all the domain hosting customers can receive
mail and log in with the full e-mail address, but the code to make
usernames without an @domain.com isn't there. The problem apparently lies
with the router I quote below.

The basic gist is that user accounts are stored in a MySQL database for
Dovecot (that part works). I need Exim to check this database for valid
users, and when the domain part is "lightspeed.ca", it looks for the user
field in the database, with a blank domain name. Otherwise, Exim needs to
do another MySQL lookup to check to make sure both the local part and the
domain exist in the database. The pseudo code looks like this:

if $domain = "lightspeed.ca" and lookup mysql {
     SELECT CONCAT(username,'@',domain) AS email
     FROM user
     WHERE username='${quote_mysql:$local_part}'
     AND domain=''
   }
   elif match $domain lookup mysql {
     SELECT CONCAT(username,'@',domain) AS email
     FROM user
     WHERE username='${quote_mysql:$local_part}'
     AND domain='${quote_mysql:$domain}'
   }
}


The following Exim router works, but not with the users in the database
that have no domain part:

mysql_user:
  driver                = accept
  # restriction to local domains only may be a double check, as the
condition takes care of it already ;-)
  domains               = +local_domains
  condition             = ${lookup mysql{ \
                   SELECT CONCAT(username,'@',domain) AS email \
                   FROM user \
                   WHERE username='${quote_mysql:$local_part}' \
                   AND domain='${quote_mysql:$domain}' \
                   AND SMTP_allowed='YES' \
                   }{true}{false}}
  local_part_suffix     = +*
  local_part_suffix_optional
  transport             = local_mysql_delivery
  no_more