Stephen Gran on 15 Sep 2004 15:28:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Database design questions


On Wed, Sep 15, 2004 at 09:19:06AM -0400, sean finney said:
> hey stephen,
> if none of this makes sense, it's possible i just don't know enough
> about exim's configuration and how it would expect the sql backend to
> work (usually the first thing i do on a new debian box is drop exim for
> postfix, and even when i don't, debconf has already configured it for me,
> so i never see the config).

One of exim's problems (and strengths) is that it will do what you want,
how you want.  There is a good, sane stock config that comes with the
Debian packages, but any other things you want to tack on can be done in
a hugs variety of ways.  So, I can make exim do the SQL lookups however
I want, it's just getting the database structure right that's sticking
for me.

I think that having a users table and a domain table is starting to feel
like the way to go, with a link table to get the aliases right.

Somthing like:

Users:
 --------------------------------------------------------------------
| ID  |  gecos        |   forwarding address                         |
 --------------------------------------------------------------------
| int | varchar       |   varchar                                    |
 --------------------------------------------------------------------

domains:
 --------------------------------------------------------------------
| domain  |  local-or-relay   |   destination                        |
 --------------------------------------------------------------------
| varchar | enum "local" ..   | varchar                              |
 --------------------------------------------------------------------

link table:
 --------------------------------------------------------------------
| localpart  | domain          |  associated_user                    |
 --------------------------------------------------------------------
| varchar    | domains.domain  | users.id                            |
 --------------------------------------------------------------------

Then, I think, exim could do the following:
email comes in for joe@example.com - look up first if example.com is one
of our domains (select domain from domains . . . ), look up the alias 
(select * from link where localpart = '$localpart' and domain = '$domain'
. . ), and then make routing decisions based on what's returned (select
* from domains where domain = '$aliased_domain' . . . ).

I think this also gives the flexibility now to change all of joe's
forwarding in one place (user table), have multiple aliases in mulitple
domains all go to one place (associated_user), but I am not sure of how
an alias going to multiple addresses would work - several lines in the
link table, with different associated_users seems like the way to go
there, but I don't like the idea of the same alias being repeated over
and over.  Maybe that is the only way to do it, though.

Thanks for letting me think aloud :)  Any other ideas also helpful.
-- 
 --------------------------------------------------------------------------
|  Stephen Gran                  | The sum of the Universe is zero.        |
|  steve@lobefin.net             |                                         |
|  http://www.lobefin.net/~steve |                                         |
 --------------------------------------------------------------------------

Attachment: pgpAI5H4zm4Ot.pgp
Description: PGP signature