0

Hi I'd like to dynamically add users to postfix, using a php service I am writing, but I'd like to keep the /etc/alias mechanic, and I've decided the best way I can do this is make individual user.cf files each one with aliases in it. I don't want to $ echo "bob :bob" >> /etc/alias I'm sure you sympathise

EG: in a directory like /etc/alias/users/*

What i'd love to be able to do is this:

 alias_maps = hash:/etc/alias/users/*

Is this possible? How can I configure postfix to allow me to make my own dir to look after this? I can then simply check for an occurrence of this file in php and remove/rewrite it easily then restart postfix to handle name changes / new user creation.

Mr Heelis
  • 123
  • 6

1 Answers1

2

Postfix doesn't support this sort of behavior.

Ultimately you'll be better served by having postfix and your php service interacting with a mutual database, e.g. mariadb, OpenLDAP, postgres. Though I suppose of you don't need something that scales past a common host, sqlite is appropriate.

Databases really are the best things for this. There are already common ways for php to interact, and they don't require postfix to be restarted (or reloaded).

84104
  • 12,905
  • 6
  • 45
  • 76
  • yeah I deliberately don't want to do that - I've just created a single ancillary `hash:` file I called `/etc/alias/users` for PHP to use: and since every line I make in there has a unique username in it I can smoothly remove the lines with the username in it iteratively - it just takes more code. shame this was omitted, it's the most sensible way of operating imho. incidentally I didn't just have to add `alias_maps` I had to do `alias_maps = hash:/etc/aliases, hash:/etc/alias/users` and `alias_database = hash:/etc/aliases, hash:/etc/alias/users` – Mr Heelis Apr 20 '17 at 13:11