Using filestructure to for mailbox lookups

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Using filestructure to for mailbox lookups

Mark Slade
Hello,

I have a server that receives mail for a few domains.  In the past
I've used virtual_mailbox_maps to map every address from user@domain
to "domain/user/".  I'm wondering if it's possible to configure
Postfix such that when mail comes in, it checks to see if
/var/mail/domain/user/ exists, and if so delivers it.  Therefore
creating a new mailbox 'user' for any domain 'example.com' would be as
simple as creating a maildir under '/var/mail/example.com/user/'.

Is this possible?  Are there drawbacks I should be considering?

I'll settle for a prod to the right part of the manual.  After reading
through VIRTUAL_README I don't see any clues that this is possible,
but wanted to check here to be certain.


Thanks,
Mark
Reply | Threaded
Open this post in threaded view
|

Re: Using filestructure to for mailbox lookups

Magnus Bäck
On Sunday, June 08, 2008 at 21:51 CEST,
     Mark Slade <[hidden email]> wrote:

> I have a server that receives mail for a few domains.  In the past
> I've used virtual_mailbox_maps to map every address from user@domain
> to "domain/user/".  I'm wondering if it's possible to configure
> Postfix such that when mail comes in, it checks to see if
> /var/mail/domain/user/ exists, and if so delivers it.  Therefore
> creating a new mailbox 'user' for any domain 'example.com' would be as
> simple as creating a maildir under '/var/mail/example.com/user/'.

Not possible. What problem are you trying to solve?

smtpd(8) must be able to determine if a user is valid, and having it
check the existence of a directory in order to find that out would not
only be ugly, it would make it impossible to chroot smtpd(8) (unless a
new type of server would provide this information to smtpd(8), but that
would be an unreasonable amount of work for, at best, very little benefit).

[...]

--
Magnus Bäck
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Using filestructure to for mailbox lookups

Mark Slade
On Sun, Jun 8, 2008 at 4:04 PM, Magnus Bäck <[hidden email]> wrote:

> On Sunday, June 08, 2008 at 21:51 CEST,
>     Mark Slade <[hidden email]> wrote:
>
>> I have a server that receives mail for a few domains.  In the past
>> I've used virtual_mailbox_maps to map every address from user@domain
>> to "domain/user/".  I'm wondering if it's possible to configure
>> Postfix such that when mail comes in, it checks to see if
>> /var/mail/domain/user/ exists, and if so delivers it.  Therefore
>> creating a new mailbox 'user' for any domain 'example.com' would be as
>> simple as creating a maildir under '/var/mail/example.com/user/'.
>
> Not possible. What problem are you trying to solve?
>
> smtpd(8) must be able to determine if a user is valid, and having it
> check the existence of a directory in order to find that out would not
> only be ugly, it would make it impossible to chroot smtpd(8) (unless a
> new type of server would provide this information to smtpd(8), but that
> would be an unreasonable amount of work for, at best, very little benefit).
>
> [...]
>
> --
> Magnus Bäck
> [hidden email]
>


Magnus,

That's the kind of answer I was looking for.  I wasn't trying to solve
a problem so much as curious if Postfix could do it.  I've ran a
personal Postfix server for a few years but my grasp on its
configuration has been tenuous at best.  I'm trying now to go though
and thoroughly understand its capabilities and this question came to
mind in the process.

Thanks!
Mark
Reply | Threaded
Open this post in threaded view
|

Re: Using filestructure to for mailbox lookups

Wietse Venema
In reply to this post by Mark Slade
Mark Slade:
> I have a server that receives mail for a few domains.  In the past
> I've used virtual_mailbox_maps to map every address from user@domain
> to "domain/user/".  I'm wondering if it's possible to configure
> Postfix such that when mail comes in, it checks to see if
> /var/mail/domain/user/ exists, and if so delivers it.  Therefore

Postfix currently does not have a lookup table mechanism that splits
user@domain, reverses it, and generates a pathname.  Adding one should
not be hard.  Otherwise, the best best is to use a policy daemon.
Be sure to not allow / in the domani or user part.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Using filestructure to for mailbox lookups

Wietse Venema
Wietse Venema:

> Mark Slade:
> > I have a server that receives mail for a few domains.  In the past
> > I've used virtual_mailbox_maps to map every address from user@domain
> > to "domain/user/".  I'm wondering if it's possible to configure
> > Postfix such that when mail comes in, it checks to see if
> > /var/mail/domain/user/ exists, and if so delivers it.  Therefore
>
> Postfix currently does not have a lookup table mechanism that splits
> user@domain, reverses it, and generates a pathname.  Adding one should
> not be hard.  Otherwise, the best best is to use a policy daemon.
> Be sure to not allow / in the domani or user part.

To answer Magnus's objection, the proxymap service can overcome
chroot restrictions in the usual manner.

        Wieste
Reply | Threaded
Open this post in threaded view
|

Re: Using filestructure to for mailbox lookups

Michael Orlitzky
In reply to this post by Mark Slade
Mark Slade wrote:

> Hello,
>
> I have a server that receives mail for a few domains.  In the past
> I've used virtual_mailbox_maps to map every address from user@domain
> to "domain/user/".  I'm wondering if it's possible to configure
> Postfix such that when mail comes in, it checks to see if
> /var/mail/domain/user/ exists, and if so delivers it.  Therefore
> creating a new mailbox 'user' for any domain 'example.com' would be as
> simple as creating a maildir under '/var/mail/example.com/user/'.
>
> Is this possible?  Are there drawbacks I should be considering?
>
> I'll settle for a prod to the right part of the manual.  After reading
> through VIRTUAL_README I don't see any clues that this is possible,
> but wanted to check here to be certain.

It would seem that the problem you're trying to solve is "to make it
easy to create a new virtual user in one place so that it's difficult to
mess up and non-repetitive."

If you were just curious about Postfix's capabilities, others have
pointed out that this isn't supported directly. But the goal above can
still be achieved with a simple script.

For example (on Linux), the script could take as one parameter the email
address and split it into username and domain parts. With virtual users,
you can probably just split on the '@', although you know your
environment best. Next, mkdir -p /var/mail/domain/user. Then, append the
username and domain name to your virtual access tables (wherever they
are). Finally, reload Postfix.

Take some care to make sure that you can never:

a) Clobber your access tables
b) Reload Postfix immediately thereafter

and that should be sufficient.

It might also be a good idea to have the script make a backup first in
case you're wrong about its ability to trash your files.