Re: [Exim] exim, virtual users & mysql

Top Page
Delete this message
Reply to this message
Author: Cyril Margorin
Date:  
To: exim-users-admin
CC: exim-users
Subject: Re: [Exim] exim, virtual users & mysql
Hi there, Joey Olson,

Wednesday, July 24, 2002, 5:16:07 AM, you wrote:

JO> Greetings All,


JO> I would like to install/configure exim to deliver mail to virtual users who
JO> do not have an actual account on the machine (no entry for them in
JO> /etc/passwd).


JO> I currently have all their account information (username, password, domain
JO> name etc) stored in a mysql database and have a web based login area that
JO> authenticates/interacts with it fine. I would like to have exim set up so
JO> when mail for joey@??? comes in, it checks to see if joey exists in
JO> the mysql table and if so, it puts the mail into
JO> /var/spool/mail/virtualuser/joey (Helping a friend set up a hotmail-like
JO> service).


This is my config... may be it's not clear, may be it's not
optimized... but it's work.

2Exim-Guru: Is there any bugs or errors or non-optimezed settings?

It's work with qpopper + MySQL patch.
That's why you can see `(status='1' or status='2')' in SQL query, and
strange User table.
My target was: Virtual User with Virtual Domain. Here it is:

---- MySQL tables ----
#
# Table structure for table `alias`
#

CREATE TABLE alias (
id int(10) unsigned NOT NULL auto_increment,
alias_user char(20) NOT NULL default '',
alias_domain char(20) default NULL,
target char(255) NOT NULL default '',
UNIQUE KEY id (id)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `domainlist`
#

CREATE TABLE domainlist (
id int(10) unsigned NOT NULL auto_increment,
domain char(40) NOT NULL default '',
local enum('no','yes') NOT NULL default 'yes',
relay enum('no','yes') NOT NULL default 'yes',
UNIQUE KEY id (id)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `relay_ip`
#

CREATE TABLE relay_ip (
ip char(15) NOT NULL default '',
ts int(11) NOT NULL default '0',
KEY ip (ip)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `users`
#

CREATE TABLE users (
id int(11) NOT NULL auto_increment,
username char(128) NOT NULL default '',
domain char(64) NOT NULL default '',
uid int(10) NOT NULL default '0',
gid int(10) NOT NULL default '0',
status int(2) NOT NULL default '0',
shell char(127) NOT NULL default '',
password char(32) NOT NULL default '',
UNIQUE KEY id (id),
KEY usr_domain (username,domain)
) TYPE=MyISAM;



---- configure file -----
### MAIN ###
hide mysql_servers = /email/email/email
primary_hostname = proxy.inform-mobil.ru
qualify_domain = immo.ru
local_domains = mysql;SELECT domain from domainlist WHERE local='yes' and domain='${key}'
local_domains_include_host
relay_domains = mysql;SELECT domain from domainlist WHERE relay='yes' and domain='${key}'
host_accept_relay = "localhost : 127.0.0.1 : 192.168.0.0/24 : \
                     mysql;SELECT ip FROM relay_ip WHERE ip='${sender_host_address}' \
                     AND ((UNIX_TIMESTAMP() - 180) < ts) : \
                     mysql;SELECT domain from domainlist WHERE relay='yes' and domain='${sender_host_address}'"
forbid_domain_literals
exim_user = root
exim_group = wheel
never_users = root : mailnull
host_lookup = *
ignore_errmsg_errors_after = 2d
timeout_frozen_after = 7d
log_file_path = syslog : /var/log/exim/%s.log
trusted_users = drweb
trusted_groups = drweb
message_filter = /usr/local/etc/exim/drweb-filter
message_filter_pipe_transport = filter_pipe
message_filter_reply_transport = address_reply
smtp_banner = $primary_hostname ESMTP Mail Server. Korolev MR,RU. SysAdmin email: <postmaster@???>



### TRANSPORT ###
remote_smtp:
driver = smtp

address_pipe:
driver = pipe
return_output

address_file:
driver = appendfile
delivery_date_add
envelope_to_add
return_path_add

virtual_delivery:
driver = appendfile
file = /var/mail/$domain/$local_part
delivery_date_add
envelope_to_add
return_path_add
user = pop
group = mail
mode = 0660

filter_pipe:
driver = pipe
user = drweb
group = drweb
log_output


### DIRECTORS ###
virtual_aliases:
driver = aliasfile
search_type = mysql
query = "select target from alias where alias_user='${local_part}' and (alias_domain='${domain}' or alias_domain IS NULL)"
qualify_preserve_domain
file_transport = address_file
pipe_transport = address_pipe

virtual_user:
driver = aliasfile
search_type = mysql
query = "select username from users where username='${local_part}' and domain='${domain}' and (status='1' or status='2')"
transport = virtual_delivery

### ROUTERS ###
lookuphost:
driver = lookuphost
transport = remote_smtp


### RETRY ###
*                      *           F,2h,15m; G,16h,1h,1.5; F,4d,8h


### REWRITE ###

### AUTH ###
---------------------- end of config -----------





--
Sinecerelu Yours
Cyril Margorin
System Administrator LTD "Inform-Mobil"
ICQ#13311146
tel.: +7(095)504-4709(work) +7(501)430-7980(cell)