Hello, 

Configuration 
OS: RHEL 5.3
MTA: mail_version = 2.7.3

I would like to rewrite messages sender header using the 
"sender_canonical_maps" feature.
Something like that below to remove the location part in () if any for the 
test.fr sender domain.
from: alain (rennes) <al...@test.fr> => from: alain <alain.guit...@test.fr>

I configured Postfix this way:
sender_canonical_classes = header_sender
sender_canonical_maps = regexp:/etc/postfix/sender_canonical_regexp
remote_header_rewrite_domain = test.fr
local_header_rewrite_clients =

with sender_canonical_regexp
/^(.*)\(.+\)\s*(.*)$/ ${1}${2}

It did not work as expected as if the rewriting only applied on the sender @ 
part.
Maillog extract : 

Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: cleanup_header_callback: 
'from: alain (rennes) <al...@test.fr>'
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: rewrite_sender: From
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: send attr request = rewrite
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: send attr rule = remote
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: send attr address = 
al...@test.fr
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: private/rewrite socket: 
wanted attribute: flags
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: input attribute name: flags
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: input attribute value: 0
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: private/rewrite socket: 
wanted attribute: address
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: input attribute name: 
address
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: input attribute value: 
al...@test.fr
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: private/rewrite socket: 
wanted attribute: (list terminator)
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: input attribute name: (end)
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: rewrite_clnt: remote: 
al...@test.fr -> al...@test.fr
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: dict_regexp_lookup: 
/etc/postfix/sender_canonical_regexp: al...@test.fr
Jan 3 16:56:26 rhel53-ag-fe1 postfix/cleanup[22775]: maps_find: 
sender_canonical_maps: al...@test.fr: not found

I made a new test removing the "sender_canonical_maps" configuration then using 
the "header_checks" feature.
header_checks = regexp:/etc/postfix/header_checks
with /etc/postfix/header_checks
/^(From: .*)\(.+\)\s*(.*)$/ REPLACE ${1}${2}

And here it worked as expected.

Question: Why doesn't it work with the "sender_canonical_maps" configuration ?

Thank you for Your Help
and Happy New Year 

Alain

Reply via email to