Re: [Exim] Exim 4 and MySQL

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Clive Goodhead
Date:  
À: exim-users
Sujet: Re: [Exim] Exim 4 and MySQL
>
> Is there anybody who can, please, send me a working sample of the
> configuration file for Exim 4 looking up users at a MySQL DB?!
>


We use the following for exim 4.02.

The MySQL database stores user information in a table called
ciusers in the following fields:

email address    email
home directory   home


plus others not relevant to exim. All virtual users have a uid and
gid of 1000. We use Maildirs.

In Local/Makefile, inter alia, we set:

LOOKUP_MYSQL=yes
LOOKUP_INCLUDE=-I /usr/local/include/mysql
LOOKUP_LIBS=-L /usr/local/lib/mysql -lmysqlclient

but it will depend on your system.

In the exim runtime configuration file we have:

Main section:

hide mysql_servers = localhost/users/[mysqluser]/[mysqlpassword]

[Words in square brackets need to be a valid MySQL username and
password.]

Routers:

# This router matches virtual users.
mysql_user:
  driver = accept
  condition = \
   ${if eq {} \
   {${lookup mysql {select home from ciusers \
    where email='${local_part}@${domain}'}}} \
   {no}{yes}}
  retry_use_local_part
  transport = mysql_delivery


I can't remember why I wrote the condition test quite like
that but it works!

Transport:

# This transport is used for virtual user delivery to maildirs.
mysql_delivery:
  driver = appendfile
  maildir_format
  directory = \
   ${lookup mysql{select home from ciusers \
    where email='${local_part}@${domain}'}}/Maildir
  user = 1000
  group = 1000


We also have many more settings for forwarding and aliases, etc.,
and system users authenticated using PAM, but if you can get the
above working for delivery to mailboxes you should be able to
work whatever else you need for yourself by reading the manual
and/or book.

Hope this helps.

Regards

Clive Goodhead
Cornwall Internet Limited
--------------------------------------------------------------------------
Cornwall Internet Limited
Registered office: Montaza, Fore Street, Goldsithney, Penzance, Cornwall.
Registered in England, registered number 3387326.
--------------------------------------------------------------------------