Postfix and .forward files: mail forwarding

aliasesemailforwardingpostfix

First of all: I'm working on a rented server setup here (hosted at Ulyssis.org). I only have access to my user folder (/home/preparee) folder and an online application that allows me to manage my account, and set up mail aliases.

Now, I want to be able to manage mail forwards for my domain, which is called preparee.be. Preparee is our organisation. In the past, we just added users to mail forwarding manually using the online application. Now, I'm developing a PHP solution to manage our organisation. I wanted to be able to control the mail forwards from PHP, without having to manually visit the online tool every time. I've got all the mail adresses in a MySQL database, seems a bit silly to manually copy them and paste them in the online tool every time.

For example:

tabasco@preparee.be -> (list of board mail addresses)
pudding@preparee.be -> (list of regular members mail addresses)

The admins told me to do the following:

  1. In the online tool, make sure the mail is delivered to "Inbox" (which seems to be the postfix inbox)
  2. In the online tool, define (for example) pudding@preparee.be to forward to preparee+pudding@ulyssis.org
  3. In my home directory, create a file called ".forward+pudding", and make it contain the line-seperated mail addresses the mails should be forwarded too when they arrive at pudding@preparee.be

I was told postfix should try to "match" the incoming mail to these .forward files, and use the most specific .forward file.

Well, this doesn't work. The only thing that works is if I define mail addresses in the regular ".forward" file, but that file just seems to get used if all else fails. I've tried poking around with the user rights to read the .forward files, tried other syntax than line-seperation, but to no avail.

I've checked the postfix documentation, but it is quite archaic, and no info seems to match the restricted environment in which I'm working (only access to home directory, I can't even access the postfix logs).

Anybody with experience with this type of forwarding?

Best Answer

The behavior is described in http://www.postfix.org/local.8.html in the paragraph of Address Extension:

   For  example,  with  "recipient_delimiter  =  +", mail for
   name+foo is delivered to the  alias  name+foo  or  to  the
   alias  name,  to  the  destinations  listed in ~name/.for-
   ward+foo or in ~name/.forward, to the mailbox owned by the
   user name, or it is sent back as undeliverable.

But to be honest: Ditch that provider. Letting you configure mail forwarding only by .forward files is technology of the last century.