Thanks very much, appreciate the detailed explanation. Everything seems to working as advertised.
On Mon, Dec 30, 2019 at 7:32 AM Wietse Venema <wie...@porcupine.org> wrote: > > Wietse Venema: > > Stats Student: > > > Hi, I would like to configure Postfix to do the following: > > > > > > 1) receive messages for users in a Postgres database and hand those > > > messages to an external script for processing (no traditional > > > mailstore). The server handles mail for only one domain. > > With a few minor refinements: > > Postfix chooses the delivery method based on the recipient domain > (the part on the right-hand side of the '@'). > > Here, we direct mail for example.com to your message store, and we > make sure that all cronjob mail comes from r...@example.com, > w...@example.com etc. > > This uses the name 'mailstore' for all things related to your > database. Of course you can use a different name. > > /etc/postfix/main.cf > virtual_transport = mailstore > mailstore_destination_recipient_limit=1 > virtual_mailbox_domains = example.com > virtual_mailbox_maps = hash:/etc/postfix/mailstore-users > myorigin = example.com > mydestination = > > /etc/postfix/master.cf: > # Requires mailstore_destination_recipient_limit=1 in main.cf. > mailstore unix - n n - - pipe > flags=DRXhu user=vmail argv=/path/to/script ${recipient} > > /etc/postfix/mailstore-users: > f...@example.com whatever > b...@example.com whatever > > This requires that you have have a UNIX system account 'vmail' > (command: useradd vmail). Of course you can use a different name. > > Once you have this working, replace hash:/etc/postfix/mailstore-users > with a pgsql table that returns a non-emnpty string for existing > users, and 'not found' otherwise. See "man pgsql_table", especially > the section "LIST MEMBERSHIP". > > > 2) for a handful of accounts (postmaster, help, root), the messages > > should be forwarded to another address (different domain). Would be > > great for this forwarding to take place without going through the > > processing script in (1). > > Use virtual_alias_maps: > > /etc/postfix/main.cf: > virtual_alias_maps = hash:/etc/postfix/virtual > > /etc/postfix/virtual: > postmaster user1@example > root user2@example > help user3@example > > No need to muck with content filters. > > Wietse