Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: exim: users

Best approach for simple MySQL & 'Virtual' Domain/Users?

 

 

exim users RSS feed   Index | Next | Previous | View Threaded


exim.ml at riotm

Apr 10, 2012, 1:33 AM

Post #1 of 3 (350 views)
Permalink
Best approach for simple MySQL & 'Virtual' Domain/Users?

I'm looking to deploy a simple Exim instance which does nothing more
than accept inbound email based upon a simple MySQL query.

The word 'Virtual' domains and users can be a little muddy at times, but
by it I mean the server will take mail for various domains and
recipients - rather than users of the operating system itself.

The file structure the transport will append to
is /var/mail/<DOMIAN>/<RECIPIENT>

And the SQL to check the domain and recipient are valid is:

SELECT mailbox FROM mailusers WHERE domain='${quote_mysql:$domain}' AND
username='${quote_mysql:$local_part}' AND remote=0;

For the life of me I can't remember how to set this up! I can't figure
which ROUTER to set up to do this.

I have a feeling I'll need an ACL on that query which I then pick out
with a router - but before I go barking up the wrong tree, is there a
simple way of having the router jump to a transport if the query
matches, whilst expanding 'domain' and 'local_part' along the way?

The transport, I guess, will be something like this:
local_mysql_delivery:
driver = appendfile
directory = /var/mail/${domain}/${local_part}/
maildir_format
delivery_date_add
envelope_to_add
return_path_add

It's just the routing that is making me struggle a little. It's probably
really obvious, but I'm not the smartest guy in the world.

Any pointers or help appreciated.

Ron




--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


jgh at wizmail

Apr 10, 2012, 1:55 AM

Post #2 of 3 (335 views)
Permalink
Re: Best approach for simple MySQL & 'Virtual' Domain/Users? [In reply to]

On 10/04/2012 09:33, Ron White wrote:
> For the life of me I can't remember how to set this up! I can't figure
> which ROUTER to set up to do this.

There's nothing special about particular routers. They do what you've
configured them to, in the order they're run. So "which router"
depends entirely on your specific configuration. You'd need to
share it with us to get more specific help.

> I have a feeling I'll need an ACL on that query

Yes, _or_ carefully write the routers to validate the address and
have your rcpt acl do a verify=recipient (which calls the routers
in verify mode). Look around the documentation
(http://exim.org/exim-html-current/doc/html/spec_html/index.html).

> is there a
> simple way of having the router jump to a transport if the query
> matches, whilst expanding 'domain' and 'local_part' along the way?

You could fill in "address_data". Or, as you have it:
>
> The transport, I guess, will be something like this:
> local_mysql_delivery:
> driver = appendfile
> directory = /var/mail/${domain}/${local_part}/

... just have the transport use the original. "jump to a transport"
is merely specifying on the router which transport to use.

--
Cheers,
Jeremy


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


S2_u220 at riotm

Apr 10, 2012, 2:19 AM

Post #3 of 3 (336 views)
Permalink
Re: Best approach for simple MySQL & 'Virtual' Domain/Users? [In reply to]

On Tue, 2012-04-10 at 09:55 +0100, Jeremy Harris wrote:
> On 10/04/2012 09:33, Ron White wrote:
> > For the life of me I can't remember how to set this up! I can't figure
> > which ROUTER to set up to do this.
>
> There's nothing special about particular routers. They do what you've
> configured them to, in the order they're run. So "which router"
> depends entirely on your specific configuration. You'd need to
> share it with us to get more specific help.
>
> > I have a feeling I'll need an ACL on that query
>
> Yes, _or_ carefully write the routers to validate the address and
> have your rcpt acl do a verify=recipient (which calls the routers
> in verify mode). Look around the documentation
> (http://exim.org/exim-html-current/doc/html/spec_html/index.html).
>
> > is there a
> > simple way of having the router jump to a transport if the query
> > matches, whilst expanding 'domain' and 'local_part' along the way?
>
> You could fill in "address_data". Or, as you have it:
> >
> > The transport, I guess, will be something like this:
> > local_mysql_delivery:
> > driver = appendfile
> > directory = /var/mail/${domain}/${local_part}/
>
> ... just have the transport use the original. "jump to a transport"
> is merely specifying on the router which transport to use.
>
> --
> Cheers,
> Jeremy
>
>
Thank you Jeremy,

I'll look around the ACL's for valid recipients.

Currently, I've got this pair work, but I will need to add further logic
to make sure I don't accept mail for domains/users not in the database.


begin routers
virtual_local:
driver = redirect
data = ${lookup mysql{SELECT mailbox FROM mailusers WHERE
domain='${quote_mysql:$domain}' AND username='${quote_mysql:
$local_part}' AND remote=0;}}
file_transport = local_mysql_delivery


transports:
local_mysql_delivery:
driver = appendfile
directory = /var/mail/${domain}/${local_part}/
maildir_format

Thanks again



--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

exim users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.