What I am trying to achieve is that any email coming to [email protected]
gets rewritten to [email protected]
and delivered to [email protected]
.
Both canonical_maps
and virtual_alias_maps
work for delivering to the alternate recipient. When I read the doc it tells me that with the canonical_maps
, cleanup
does a full rewrite.
However, in practice the email still has the to
of the original recipient. So when looking at the email in bob's mailbox, it shows an email to joe.
Somehow I feel I am missing something here.
Configuration:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
bounce_queue_lifetime = 2d
canonical_maps = hash:/etc/postfix/canonical
config_directory = /etc/postfix
header_checks = pcre:/etc/postfix/header_checks
home_mailbox = Maildir/
html_directory = /usr/share/doc/postfix/html
inet_interfaces = all
mailbox_size_limit = 0
maximal_queue_lifetime = 4d
milter_default_action = accept
milter_protocol = 2
mydestination = ...
myhostname = ...
mynetworks = ...
myorigin = /etc/mailname
non_smtpd_milters = inet:localhost:8891
readme_directory = /usr/share/doc/postfix
recipient_delimiter = +
relayhost =
smtp_fallback_relay = ...
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name
smtpd_milters = inet:localhost:8891
smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access permit_mynetworks reject_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
transport_maps = hash:/etc/postfix/transport
virtual_alias_maps = hash:/etc/postfix/virtual
Logs:
Sep 25 09:40:30 server1 postfix/smtpd[28285]: connect from mail-la0-f66.google.com[209.85.215.66]
Sep 25 09:40:31 server1 postfix/smtpd[28285]: 7CA784EDB6: client=mail-la0-f66.google.com[209.85.215.66]
Sep 25 09:40:31 server1 postfix/cleanup[28339]: 7CA784EDB6: message-id=<CAJjncucnGM532xhcn37VAwmwQoYEwOUfE_A33-oyJJH5PqPUcA@mail.gmail.com>
Sep 25 09:40:31 server1 postfix/qmgr[7593]: 7CA784EDB6: from=<[email protected]>, size=1813, nrcpt=1 (queue active)
Sep 25 09:40:32 server1 postfix/smtpd[28285]: disconnect from mail-la0-f66.google.com[209.85.215.66]
Sep 25 09:40:32 server1 postfix/smtp[28593]: 7CA784EDB6: enabling PIX workarounds: disable_esmtp delay_dotcrlf for ...[...]]:25
Sep 25 09:40:33 server1 postfix/smtp[28593]: 7CA784EDB6: to=<[email protected]>, orig_to=<[email protected]>, relay=...[...]:25, delay=1.6, delays=0.45/0/0.42/0.73, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 98F729600E)
Sep 25 09:40:33 server1 postfix/qmgr[7593]: 7CA784EDB6: removed
From the mail.log, looks like you want to rewrite the email from the remote client. The default setting of postfix rewrite prevent this happened.
Excerpt from Postfix Rewriting README
So, the simplest solution is don't leave parameter
remote_header_rewrite_domain
with empty value. You need to provide value to this parameter with value such asOr you can use
static:all
on parameterlocal_header_rewrite_clients
so postfix will consider all remote client as local.Source: Official docs of Postfix Address Rewriting