0

I am running a mail server with Postfix, and I have set this line in /etc/postfix/header_checks.pcre:

/^To: board@example.org/  PREPEND Reply-To: board@example.org

Board@Example.org is a forwarding address. If someone sends an email to Board@Example.org, it'll forward to a number of other addresses. However, I want the Reply-To line to be Board@Example.org, so all replies go to everyone.

My line works, but the problem is that it's adding the 'Reply-To' header twice. I suspect the mail server is receiving the message, prepending the line, then sending out emails to each of the recipients, adding the line again. I have tried this:

if /^To: board@example.org/
!/^Reply-To: board@example.org/  PREPEND Reply-To: board@example.org
endif

The logic here is 'if this is going to board@example.org, and the Reply-To header is not board@example.org, then prepend the Reply-To header. The problem is, this still doesn't work. It adds the Reply-To header twice.

My understanding is that postfix header_checks can't determine whether a header is present or not, only what the content of it is. I am at a loss as to how to get this header going in only once.

3x5
  • 121
  • 3

1 Answers1

0

OK, I do have a working solution for this now. In /etc/postfix/main.cf, make sure you have this line:

header_checks = pcre:/etc/postfix/header_checks.pcre

Note that this starts with header_checks and not smtp_header_checks. Then, inside this file:

/^To:.*board@example\.org/ PREPEND Reply-To: <board@example.org>
/^(Reply-To:.*)board@example\.org/ IGNORE

So there it is. If the email is going to a specific address, add the Reply-To header. Also, if the Reply-To header is already what you want, do nothing.

I don't know why it works this way, despite there being no nested condition and despite the order seeming to be incorrect, but after trying quite a lot of options, this one is working for me, consistently. I hope this helps you too.

3x5
  • 121
  • 3
  • Sorry, I had what I thought was a solution, but it was buggy so I removed it. I just posted the fixed, correct solution. – 3x5 Jul 17 '23 at 14:02