Skip to Content.
Sympa Menu

en - fun with auto aliases with postfix

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: elijah <address@concealed>
  • To: "address@concealed" <address@concealed>
  • Subject: fun with auto aliases with postfix
  • Date: Wed, 7 May 2003 12:09:28 -0700 (PDT)

If you have a virtual domain where all the addresses are going to be for
lists, there is a neat trick you can do with postfix so that you don't
ever need to update the aliases or virtual files.

-elijah

Here is how to do this:

---------------------------------------------------------------------

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 can take this one step further by using regular expression based
virtual aliases so that all we need is one set of entries per domain.

/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 $address@concealed"
mydomain-request: "| /home/sympa/bin/queue
$address@concealed"
mydomain-editor: "| /home/sympa/bin/queue
$address@concealed"
mydomain-owner: "| /home/sympa/bin/bouncequeue $address@concealed"
mydomain-subscribe: "| /home/sympa/bin/queue
$address@concealed"
mydomain-unsubscribe: "| /home/sympa/bin/queue
$address@concealed"

What does this do? Lets look at the first line: it takes the address
'mydomain' and pipes it to the command "|/queue $address@concealed".
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:

address@concealed mydomain+mylist

This would forward mail sent to address@concealed 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$/ $address@concealed
/^(.*)-(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:

address@concealed mydomain-subscribe+mylist
address@concealed mydomain-owner+mylist

The forth line will resolve like this:

address@concealed 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".

after you have made theses changes, run postalias on the aliases file (or
newaliases). you do not need to run postmap when you make changes to the
virtual.regexp file (since it is not a hash but a table of regular
expressions). a 'postfix reload' will make these changes show up right
away'

This alias setup is adapted from the mailman+postfix setup described at
http://listes.rezo.net/how.php.


  • fun with auto aliases with postfix, elijah, 05/07/2003

Archive powered by MHonArc 2.6.19+.

Top of Page