Howto setup postfix on Debian
Posted by admin on December 06 2006 16:01:15

Install Packages

> apt-get install postfix postfix-tls postfix-pcre

Aliases

Normally, sympa requires several aliases for each list in order to pipe different addresses to different commands. This can only be done in non-virtual alias file, so a little trickiery is needed to map the virtual aliases to non-virtual aliases.
We take this one step further by using regular expression based virtual aliases so that all we need is one set of entries per domain. You cannot use this method if your list server is not set up for virtual domains.
/etc/postfix/main.cf:
virtual_maps = regexp:/etc/postfix/virtual.regexp
recipient_delimiter = +

The recipient_delimiter of '+' is the default, but it is required for the trick to work so we set it explicitly.
/etc/postfix/aliases:
mydomain:              "| /home/sympa/bin/queue $EXTENSION@my.domain.org"
mydomain-request:      "| /home/sympa/bin/queue "EXTENSION-request@my.domain.org"
mydomain-editor:       "| /home/sympa/bin/queue $EXTENSION-editor@my.domain.org"
mydomain-owner:        "| /home/sympa/bin/bouncequeue $EXTENSION@my.domain.org"
mydomain-subscribe:    "| /home/sympa/bin/queue $EXTENSION-subscribe@my.domain.org"
mydomain-unsubscribe:  "| /home/sympa/bin/queue $EXTENSION-unsubscribe@my.domain.org"

What does this do? Lets look at the first line: It takes the address 'mydomain' and pipes it to the command "|/queue $EXTENSION@my.domain.org". But what does $EXTENSION equal? This variable will hold our list name. In order to set the $EXTENSION variable to the list name, we use a + to add an additional recipient in the virtual aliases file.
Suppose we had the virtual alias:
mylist@my.domain.org mydomain+mylist
This would forward mail sent to mylist@my.domain.org to the local address mydomain with the additional recipient of 'mylist'. When we resolve the address 'mydomain' in the aliases file, the variable $EXTENSION will then be set to 'mylist'.
Instead of creating a virtual alias like this for each list, we use regular expressions to cover all lists.
/etc/postfix/virtual.regexp:
/^my\.domain\.org$/           xxx
/^(postmaster|root|abuse)@my\.domain\.org$/   $1@otherdomain.org
/^(.*)-(request|editor|owner|subscribe|unsubscribe)@my\.domain\.org$/ mydomain-$2+$1
/^(.*)@my\.domain\.org$/      "mydomain+$1"

The first line just tells postfix we are handling mail for the virtual domain my.domain.org. The xxx is just a placeholder, but it is required. The second line catches important addresses which we do not want processed as lists. You can forward these non-list addresses to another domain or use the same domain. The third line is where it gets interesting. Here is an example of how this expression will resolve:
mylist-subscribe@my.domain.org mydomain-subscribe+mylist mylist-owner@my.domain.org mydomain-owner+mylist
The forth line will resolve like this:
mylist@my.domain.org mydomain+mylist
Which is what we need for the alias file we have set up.
Note the difference between my.domain.org and mydomain. The first is the actual domain. The second is an arbitrary tag which we have chosen to associate with the domain.
To make sure that postfix can handle the regular expression map type:
> postconf -m

This will give you a list of supported map types. Check for "regexp".
This alias setup is adapted from the mailman+postfix setup described at listes.rezo.net/how.php.

Exim

reportedly, this in exim will do the same thing:
Routers:
sympa_user:
        driver = accept
        domains = scooter.mupp.net
        local_parts = sympa
        transport = sympa_pipe

sympa:
        driver = accept
        require_files = /home/sympa/expl/$local_part
        transport = sympa_pipe



sympa_special:
        driver = accept
        transport = sympa_special_pipe
        local_part_suffix  =  -request : -editor : -unsubscribe
        require_files = /home/sympa/expl/$local_part

sympa_subscribe:
        driver = accept
        transport = sympa_subscribe_pipe
        local_part_suffix  =  -subscribe
        require_files = /home/sympa/expl/$local_part

sympa_owner_bounce:
        driver = accept
        transport = sympa_owner_bounce_pipe
        local_part_suffix = -owner
        require_files = /home/sympa/expl/$local_part

sympa_bounce:
        driver = accept
        local_part_prefix = bounce+
        transport = sympa_bounce_pipe


Transports:
sympa_pipe:
        driver = pipe
        command = "/home/sympa/bin/queue $local_part"
        return_path_add
        delivery_date_add
        envelope_to_add
        user = nobody
        group = nogroup

sympa_special_pipe:
        driver = pipe
        command = "/home/sympa/bin/queue $local_part$local_part_suffix"
        return_path_add
        delivery_date_add
        envelope_to_add
        user = nobody
        group = nogroup

sympa_subscribe_pipe:
        driver = pipe
        command = "/home/sympa/bin/queue
$local_part$local_part_suffix@$domain@$domain"
        return_path_add
        delivery_date_add
        envelope_to_add
        user = sympa
        group = sympa

sympa_owner_bounce_pipe:
        driver = pipe
        command = "/home/sympa/bin/bouncequeue $local_part@$domain"
        return_path_add
        delivery_date_add
        envelope_to_add
        user = sympa
        group = sympa

sympa_bounce_pipe:
        driver = pipe
        command = "/home/sympa/bin/bouncequeue sympa@scooter.mupp.net"
        return_path_add
        delivery_date_add
        envelope_to_add
        user = nobody
        group = nogroup