I've a Red Hat Enterprise Linux Server release 7.6 (Maipo) with postfix version 2.10.1. I use it as relay only - no local mailboxes.

This server should be used to rewrite addresses. I've tried it with recipient_canonical and virtual. And in general it works. My problem is, that if the recipient get the mail and click on "reply to all" (e.g. in Outlook) I would excpect, only to see the sender address. But in fact I see the old (before rewritten) address of the recipient as well. This would mean that with "reply to all" "I" would send a mail to myself, using my old address.

Example: postfix receive the mail from sender@foo.tld to whoever@old_domain.tld. With recipient_canonical recipient address will be rewritten to whoever@new_domain.tld and postfix deliver this mail to the next hop. If now whoever@new_domain.tld press "reply to all" on his mail client sender@foo.tld appears (as expected), but whoever@old_domain.tld as well. This is not wanted.

What I do wrong here? Thank you very much in advance!

Supplement: At gmx I still see the old address and gmx put it in CC

recipient_canonical_classes = envelope_recipient, header_recipient

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix

myhostname = srv5240.xxxxx.com
mydomain = xxxxxxx^.com
myorigin = $myhostname

inet_interfaces = all
inet_protocols = ipv4

mydestination = $myhostname, localhost.$mydomain, localhost

unknown_local_recipient_reject_code = 550

mynetworks_style = host
mynetworks = $config_directory/mynetworks

transport_maps = hash:$config_directory/transport

smtpd_recipient_restrictions =

relayhost = [smtpdo.xxxxx.com]
smtp_fallback_relay = [smtpkr.xxxxx.com]

alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases

smtpd_banner = $myhostname ESMTP - AM redirector
smtp_helo_name = $myhostname

debug_peer_level = 2
debugger_command =
         ddd $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES

canonical_classes = envelope_sender, envelope_recipient, header_sender, header_recipient
canonical_maps = hash:$config_directory/canonical

sender_canonical_classes = envelope_sender
#sender_canonical_maps = hash:$config_directory/sender_canonical

recipient_canonical_classes = envelope_recipient, header_recipient
#recipient_canonical_maps = mysql:$config_directory/recipient_canonical.cf
#recipient_canonical_maps = hash:$config_directory/recipient_canonical

2bounce_notice_recipient = postmaster
bounce_notice_recipient = postmaster
bounce_queue_lifetime = 5d
bounce_template_file = $config_directory/bounce.cf

delay_warning_time = 4h

parent_domain_matches_subdomains = no
disable_vrfy_command = yes
mailbox_size_limit = 51200000
message_size_limit = 20480000
abc@gemini.local   abc@gmx.de
header (shorten/anonymous)
Return-Path: <hajo@xxxxx.com>
Received: from  by mx-ha.gmx.net
(mxgmx012 []) with ESMTPS (Nemesis) id 0MKuG0-1hD1KR1CWO-0000n8
for <abc@gmx.de>; Sun, 07 Apr 2019 08:30:55 +0200
Received: from )
                (using TLSv1 with cipher AES256-SHA (256/256 bits))
                (No client certificate requested)
                by srv1712 (Postfix) with ESMTPS id CE70D6492E
                for <abc@gemini.local>; Sun,  7 Apr 2019 08:30:53 +0200 (CEST)
From: Test <hajo@xxxx.com>
To: "abc@gemini.local" <abc@gemini.local>
Subject: can
Thread-Topic: can
Thread-Index: AQHU7Qt7FsBD4dMMv0S8fIYyFhmRWQ==
Date: Sun, 7 Apr 2019 06:31:07 +0000
Message-ID: <10c4f38c658b4a0c8dd7887d75ae5d7d@xxxx.com>
Accept-Language: de-DE, en-US
Content-Language: de-DE
x-originating-ip: []
Content-Type: multipart/alternative;
MIME-Version: 1.0
X-purgate: clean
X-purgate-type: clean.almost-empty
X-purgate-ID: 151534::1554618654-000004F5-1A665F12/14/0
Envelope-To: <abc@gmx.de>
X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3;
X-Spam-Flag: NO

By the way a solution with virtual would be the best for me, because the second function of the server is an auto reply which I can realise with virtual very easy.

abc@gemini.local  abc@gmx.de,abc@gmx.de@autoreply.local
autoreply.local autoreply:
smtp      inet  n       -       n       -       -       smtpd
pickup    fifo  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       n       -       -       smtp

relay     unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=

showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
autoreply  unix  -       n       n       -       -       pipe
  flags= user=nobody argv=/etc/postfix/autoreply/autoreply.sh ${sender} ${mailbox}

I see this in the header: To: "abc@gemini.local" The question how do I change it?

  • 1
    Rewriting headers might break DKIM signatures. If an address is working, it's not an old address, but a current alias. – Esa Jokinen Apr 6 '19 at 16:06
  • Hi, DKIM is not the problem. It will only affect company internal mail flow. – Hajo Apr 6 '19 at 16:21
  • I just tested it, if I apply canonical address mapping to both sender and recipient, my resulting mail does not contain the old address anywhere. Look at the mail headers, are you sure your problem is caused by recipient addresses only? – anx Apr 6 '19 at 16:48
  • I don't want to rewrite the sender. So I've never tested it in this way. This mean you I should use canonical_maps, not[sender|recipient]_canonical_maps? – Hajo Apr 6 '19 at 17:03
  • At first thank you for your support! I've added the content of the file. gemin.local ist not a vaild domain but if I try with valid one the result is the same. – Hajo Apr 7 '19 at 6:50

the problem of the header was a missing parameter in the main.cf:

local_header_rewrite_clients = static:all

Unfortunately with this solution the virtual is not usable. To generate a task for the autoreply functionality I add a BCC recipient file:

recipient_bcc_maps = hash:$config_directory/bcc
new_address@foo.tld    new_address@foo.tld@autoreply.local

Like described above autoreply.local in the transport is assigned to a script, defined in the master.cf. The parameter ${mailbox} will cut the domain (@autoreply.local) so the values for the script which was transferred are:

...autoreply.sh ${sender} ${mailbox}
...autoreply.sh sender@mailcomes_from.tld new_address@foo.tld 

The mail content will be tranferred to the script by stdin.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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