Mailing List Archive

exim, virtual users & mysql
Greetings All,

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

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

From the docs I have looked at, I know it is possible, I just haven't found
a clear-cut guide/doc detailing how to do so.

If you would be so kind to point me in the proper direction, it would be
much appreciated.

Thanks a bunch,
Joey.
Re: exim, virtual users & mysql [ In reply to ]
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@whatever.com 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@immo.ru>


### 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)
Re: exim, virtual users & mysql [ In reply to ]
From: "Joey Olson" <joey@jolson.ca>
>
> I would like to install/configure exim to deliver mail to virtual users
who
> do not have an actual account on the machine (no entry for them in
> /etc/passwd).
>
> I currently have all their account information (username, password, domain
> name etc) stored in a mysql database and have a web based login area that
> authenticates/interacts with it fine. I would like to have exim set up so
> when mail for joey@whatever.com comes in, it checks to see if joey exists
in
> the mysql table and if so, it puts the mail into
> /var/spool/mail/virtualuser/joey (Helping a friend set up a hotmail-like
> service).
>

http://www.exim.org/mailman/htdig/exim-users/Week-of-Mon-20020415/037706.htm
l

Clive Goodhead
Cornwall Internet Limited
--------------------------------------------------------------------------
Cornwall Internet Limited
Registered office: Montaza, Fore Street, Goldsithney, Penzance, Cornwall.
Registered in England, registered number 3387326.
--------------------------------------------------------------------------
Re: exim, virtual users & mysql [ In reply to ]
It is not difficult.
U'll need to add:
1. In ACL_check_rcpt section: condition, that checks
validity of RCPT To: user
Looks like:

deny domains = yourdomain.tld
!condition = \
${lookup mysql{select username from user where username='$local_part'}{yes}{no}}
message = <$local_part@$domain>... no such user

you may spcify another checks (deleted mailbox, over quota, etc..) and
acl_check_rcpt for your virtual domains must ends with:

accept domains = yourdomain.tld
endpass
verify = recipient

2. In routers section: router, that points mail for virtual domains
to virtuser_delivery transport

that's easy:
virtdomain:
driver = accept
transport = virtual_delivery
domains = yourdomain.tld

3. In transport section: specify transpor, that put mail
to virtual user dir.

virtual_delivery:
driver = appendfile
file = /var/mail/$local_part
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Here you must specify SELECT from your database,
that points exim where to store mail for $local_part
delivery_date_add
envelope_to_add
return_path_add
group = somegroup
user = someuser
mode = 0660

Of course, you may specify domain_list in 'domains=' and serving unlimited
numbers of virtual domains by that cheme.


Joey Olson wrote:
> Greetings All,
>
> I would like to install/configure exim to deliver mail to virtual users who
> do not have an actual account on the machine (no entry for them in
> /etc/passwd).
>
> I currently have all their account information (username, password, domain
> name etc) stored in a mysql database and have a web based login area that
> authenticates/interacts with it fine. I would like to have exim set up so
> when mail for joey@whatever.com comes in, it checks to see if joey exists in
> the mysql table and if so, it puts the mail into
> /var/spool/mail/virtualuser/joey (Helping a friend set up a hotmail-like
> service).
>
> >From the docs I have looked at, I know it is possible, I just haven't found
> a clear-cut guide/doc detailing how to do so.
>
> If you would be so kind to point me in the proper direction, it would be
> much appreciated.
>
> Thanks a bunch,
> Joey.
>
>
>
>
>
> --
>
> ## List details at http://www.exim.org/mailman/listinfo/exim-users Exim details at http://www.exim.org/ ##
>

--
VVS56-RIPE
Re: exim, virtual users & mysql [ In reply to ]
Awesome, I finally got it working :)

Thank you so much!

Joey.

----- Original Message -----
From: <sharun@ukr.net>
To: "Joey Olson" <joey@jolson.ca>
Cc: <exim-users@exim.org>
Sent: Wednesday, July 24, 2002 5:53 AM
Subject: Re: [Exim] exim, virtual users & mysql


> It is not difficult.
> U'll need to add:
> 1. In ACL_check_rcpt section: condition, that checks
> validity of RCPT To: user
> Looks like:
>
> deny domains = yourdomain.tld
> !condition = \
> ${lookup mysql{select username from user where
username='$local_part'}{yes}{no}}
> message = <$local_part@$domain>... no such user
>
> you may spcify another checks (deleted mailbox, over quota, etc..) and
> acl_check_rcpt for your virtual domains must ends with:
>
> accept domains = yourdomain.tld
> endpass
> verify = recipient
>
> 2. In routers section: router, that points mail for virtual domains
> to virtuser_delivery transport
>
> that's easy:
> virtdomain:
> driver = accept
> transport = virtual_delivery
> domains = yourdomain.tld
>
> 3. In transport section: specify transpor, that put mail
> to virtual user dir.
>
> virtual_delivery:
> driver = appendfile
> file = /var/mail/$local_part
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Here you must specify SELECT from your
database,
> that points exim where to store mail for $local_part
> delivery_date_add
> envelope_to_add
> return_path_add
> group = somegroup
> user = someuser
> mode = 0660
>
> Of course, you may specify domain_list in 'domains=' and serving unlimited
> numbers of virtual domains by that cheme.
>
>
> Joey Olson wrote:
> > Greetings All,
> >
> > I would like to install/configure exim to deliver mail to virtual users
who
> > do not have an actual account on the machine (no entry for them in
> > /etc/passwd).
> >
> > I currently have all their account information (username, password,
domain
> > name etc) stored in a mysql database and have a web based login area
that
> > authenticates/interacts with it fine. I would like to have exim set up
so
> > when mail for joey@whatever.com comes in, it checks to see if joey
exists in
> > the mysql table and if so, it puts the mail into
> > /var/spool/mail/virtualuser/joey (Helping a friend set up a hotmail-like
> > service).
> >
> > >From the docs I have looked at, I know it is possible, I just haven't
found
> > a clear-cut guide/doc detailing how to do so.
> >
> > If you would be so kind to point me in the proper direction, it would be
> > much appreciated.
> >
> > Thanks a bunch,
> > Joey.
> >
> >
> >
> >
> >
> > --
> >
> > ## List details at http://www.exim.org/mailman/listinfo/exim-users Exim
details at http://www.exim.org/ ##
> >
>
> --
> VVS56-RIPE
>
> --
>
> ## List details at http://www.exim.org/mailman/listinfo/exim-users Exim
details at http://www.exim.org/ ##
>