问题原文
原帖链接 · Server Fault · CC BY-SA 3.0
I have a Postfix mail gateway setup and would like to change the recipient address. I want all mail being relayed for [email omitted] to instead by relayed to [email omitted] I have Postfix configured using smtp_generic_maps (as below) however this only works for mail being generated on the Postfix server itself. Any mail being relayed through the Postfix server still goes to [email omitted] effectively ignoring smtp_generic_maps. What configuration should I look into to accomplish this?
# grep smtp_generic_maps main.cf
smtp_generic_maps = hash:/etc/postfix/generic
# postmap /etc/postfix/generic
# service postfix reload
# cat /etc/postfix/generic
[email omitted] [email omitted]
已采纳解答
原帖链接 · Esa Jokinen · CC BY-SA 3.0
You shouldn't use smtp_generic_maps for this
The Postfix Address Rewriting Readme describes the correct use for smtp_generic_maps:
With the
smtp_generic_mapsparameter you can specify generic(5) lookup tables that replace local mail addresses by valid Internet addresses when mail leaves the machine via SMTP. The generic(5) mapping replaces envelope and header addresses, and is non-recursive. It does not happen when you send mail between addresses on the local machine.
You are trying to use it (instead of replacing local addresses like [email omitted]) for replacing an address with FQDN [email omitted]. As yahoo.com is not configured in mydestination it is not considered as a local domain, thus not processed by generic(5) mapping.
However, you should not configure a domain of someone else as a local domain as it really should be handled by smtp(8) delivery agent instead. Doing so would prevent any user sending mail to any @yahoo.com address. That kind of tampering would be technically incorrect and maybe even illegal.
Leading users towards company policy by check_recipient_access
If the problem is that someone is trying to email your CEO to a personal @yahoo.com address and you would like to prevent that and force using company email [email omitted] instead, you could add a check_recipient_access restriction to your main.cf:
smtpd_recipient_restrictions =
...
check_recipient_access hash:/etc/postfix/denied_recipients,
...
permit
and then add a reject with a human readable reason into /etc/postfix/denied_recipients:
[email omitted] REJECT The CEO must be contacted using official <[email omitted]> address.
(As I used hash: in my example, don't forget to postmap /etc/postfix/denied_recipients.)
Using transport(5) table for overriding Postfix built-in defaults
In order to make all [email omitted] be delivered to [email omitted] you can use transport_maps instead of smtp_generic_maps.
DESCRIPTION
The optional transport(5) table specifies a mapping from email addresses to message delivery transports and next-hop destinations. Message delivery transports such as local or smtp are defined in the
master.cffile, and next-hop destinations are typically hosts or domain names. The table is searched by the trivial-rewrite(8) daemon.This mapping overrides the default
transport:nexthopselection that is built into Postfix.
Add transport_maps to your /etc/postfix/main.cf:
transport_maps = hash:/etc/postfix/transport
And then add to /etc/postfix/transport one line for [email omitted] altering the default transport:nexthop to virtual:[email omitted]:
[email omitted] virtual:[email omitted]
yahoo.com :
* :
The other lines just states that no modification is done for yahoo.com and the rest, falling back to the default transport:nexthop behaviour.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
