Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to configure Postfix to replace the 'From' header in all forwarded/aliased messages with a custom email address, and the 'Reply-To' header with the original sender's address. Is that something that can be done with a simple configuration change, or am I looking at a more complex problem? For example:

Original Message:

From: "John Smith" <john@smith.com>
To: "Jane Rice" <jane@mydomain.com>

Would get translated to:

From: "My Email Forwarding Service" <no-reply@mydomain.com>
Reply-To: "John Smith" <john@smith.com>
To: "Jane Rice" <jane@rice.com>

Ideally, I would also have it rewrite the message body (adding something about how the message was forwarded for them), but I know that's much more difficult. We have a number of email aliases, and everytime someone reports spam they received through their alias, our server gets flagged. I'm trying to minimize that damage as much as possible.

Any help is greatly appreciated!

share|improve this question
    
Did you ever learn of a way to solve this? I'm running into a problem and wanted to try to solve it in the same way, but I'm having trouble. My initial attempt was to use header_checks but I learned, as you commented here somewhere, that it only works for one header at a time. –  bratsche Apr 27 '13 at 21:50

5 Answers 5

To accomplish your goals (which involve significant message rewriting) you should do one of two things:

  • have postfix move all messages into the hold queue upon receipt, upon which they are mangled by a consumer process and then moved into the incoming queue (this is what MailScanner does)
  • write a Milter for sendmail & Postfix - this lets you do the complicated processing you require inline as the message is received.
share|improve this answer

The right solution is to use standards for that. Either see BATV for Postfix or VERP for Postfix. Where ever VERP is to be preferred.

share|improve this answer

Don't know if this is of any help, but maybe this post (http://thread.gmane.org/gmane.mail.postfix.user/125861/focus=125866) could be helpful to you.

I can't tell you how to add the additional Reply-To header though...

share|improve this answer

The header_cheks only lets you to change the same part what you match in the regular expression, at least is what i see in all configurations,
Ex/ if you match a regular expression like this
/^Subject: ($1).* / REPLACE Subject:
You only can change the header SUBJECT, you cant put a part os the subject in other place of the header.

share|improve this answer
    
Agreed. See my earlier comments on morgant's solution. –  inxilpro Oct 27 '10 at 12:48

All of this should be reasonable by adding some header_checks logic (see Postfix's header_checks man page), specifically the REDIRECT & REWRITE actions.

You'd want to add something like the following to your main.cf file:

header_checks = regexp:/etc/postfix/header_checks

Then include your regular expressions & actions in /etc/postfix/header_checks.

share|improve this answer
    
It looks like that wouldn't work for two reasons. The first is this: –  inxilpro Oct 18 '10 at 19:41
    
Oops! The first is this: "Message headers added by the cleanup(8) daemon itself are excluded from inspection. Examples of such message headers are From:, To:, Message-ID:, Date:." The second is the fact that I need to act on multiple headers, and header_checks only works line-by-line. –  inxilpro Oct 18 '10 at 19:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.