Enemies Of Carlotta with Postfix 2.0 and virtual domains

Well, first off, thanks Lars Wirzenius (liw) for this really fine piece of software, it saved me from the mailman hell I was going to enter.

That being said, here’s the setup, with Postfix 2.0 and virtual domains on a Sarge system; the manpage of eoc is slightly outdated wrt to Postfix it seems, so I hope this will be helpful (with apologies to Planet readers for the length of this entry):

  • Create an eoc or whatever user, who will receive the mails and hold the eoc configuration. I created a system user, with a disabled password and /bin/bash as its shell, member of the list group.
  • su - eoc and create your mailing list, with something like

    enemies-of-carlotta --name=testlist@lists.example.com --owner=foo@example.com --create

    Now, add yourself to the testlist:

    enemies-of-carlotta --name=testlist@lists.example.com --subscribe your@email.address

    As eoc places its configuration data in ~/.enemies-of-carlotta, it’s important to run the enemies-of-carlotta command as the eoc user.
  • Edit /etc/postfix/main.cf, and add the file /etc/postfix/virtual_eoc_aliases to the virtual_alias_map configuration item, e.g.

    ...
    virtual_alias_maps = hash:/etc/postfix/virtual_aliases, pcre:/etc/postfix/virtual_eoc_aliases
    ...

    Now, create /etc/postfix/virtual_eoc_aliases:

    #
    # virtual aliases for EOC (mailing-lists)
    #
     
    /^(testlist|testlist-.*)@(lists.example.com)$/ eoc+lists.example.com_$1

    This way, a mail addressed to (testlist|testlist-.*)@lists.example.com will be redirected to eoc+lists.example.com_<whatgotmatched>.

    You’ll need the postfix-pcre package for this to work, and the recipient delimiter must be set to + (recipient_delimiter = + in /etc/postfix/main.cf). Restart postfix.

  • Send a mail to your test list, it should end up in the mailbox of your eoc user. If it doesn’t, check the postfix logs and fix the problem ;-)
  • Create the .forward file in the user’s homedir, here’s its content

    "| procmail -p"
  • Now, create the .procmailrc file for the eoc user. This is what I came up with:

    PATH=$HOME/bin:/bin:/usr/bin
    LOGFILE=$HOME/eoc-log
    ARCHIVES=$HOME/archives
    THISMONTH=`date "+%Y%m"`
     
    # determine the full list name (list@domain)
    :0
    EOCLIST=| eoc-extract-list $EXTENSION
     
    # set recipient to the full list name, ie list@domain
    RECIPIENT=$EOCLIST
     
    # feed the mail to EOC
    :0
    * ? enemies-of-carlotta --name=$EOCLIST --is-list
    {
    # send the mail to the list
    :0 c
    | enemies-of-carlotta --quiet --incoming
     
    # archive it
    UMASK=033
    :0
    $ARCHIVES/$EOCLIST/${THISMONTH}.mbox
    }
     
    # trap other mails ...
    :0
    trapped-mails

    The eoc-extract-list does nothing more than that, at the moment:

    echo $1 | sed -e 's/\([^_]*\)[_]\(.*\)/\2@\1/’

    The trapped-mails mbox file will need to be emptied periodically; actually, I redirect those mails to another address, feel free to pass them on to Dave Null.
    As you can see, the mails get archived in an mbox by the procmail rule. I use mhonarc to generate a web archive from this mbox.

OK, here you are, your test mailing-list should now be functional. Send a mail, and see what happens.

To add a list, all you have to do is:

  • Add the regexp into /etc/postfix/virtual_eoc_aliases
  • Create the list in eoc

The procmailrc doesn’t need to be modified afterwards. It can probably be improved still, but I’m happy with it as it is now.

Now, if someone knows of a mailing-list archiver that doesn’t suck, I’d be glad to give it a try.

Comments are closed.