~2012

A poor mans mailinglist setup with postfix

We use the postfix MTA for our email needs. We also use our user groups for email. So if you are a member of a group you will receive mail for that group. However replies from a group mail are sent to the sender of the mail and not back to the group. This setup explains how to work around that and so create 'a poor mans' mailinglist setup.

If you have postfix installed you might want to read about the header_checks (5). Header_checks does exactly what is says, it checks headers and gives you some options for acting upon a check. So this functionality is simply used to check a certain 'to:' header. If it is matched to a regular expression a PREPEND action is set to prepend a Reply-To: header. It's as easy as that.

So in your postfix config dir (/etc/postfix) create a file with this example content:

/^To:.*(groupmail@example\.org)/ PREPEND Reply-To: groupmail@example.org
/^To:.*(grp_.*@example\.org)/ PREPEND Reply-To: $1

the first line is a simple static example. It matches for groupmail@example.org and add the Reply-To: header with the same address. The second line is more interesting. It matches a regular expression and uses the matched part to set the Reply-To header. So an email to grp_test@example.org will get a Reply-To: grp_test@example.org header.