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

I am using postfix mail server and i need to replace mail content inside every incoming and outgoing message based on some predefined rules.

What is needed is to filter remote and local mail to replace every instance of user@domain.com in header or body with user@blah.com

header_checks and body_checks options seem cumbersome, maybe there is better/faster option that works on whole message instead going line by line

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Postfix support header address rewriting at outgoing mail:

smtp_generic_maps = hash:/etc/postfix/generic_map


user@example.com    user@example.org

# postmap /etc/postfix/generic_map

Using regular expression:

smtp_generic_maps = regexp:/etc/postfix/generic_map.regexp


(.*?)@example.com    $1@example.org

Isn't supported change in body. You need create you own content filter.


share|improve this answer

You should look at content filters, as mentioned in Postfix's documentation.

You probably want to use a before-queue content filter. This can probably be written fairly easily in something like Perl or Python. The Postfix guide for before-queue filters also links to a program called smtpprox which you might be able to repurpose for your needs.

share|improve this answer

Your Answer


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.