问题原文
原帖链接 · kindzmarauli · CC BY-SA 4.0
What is the right way to add a different relay for "from" email addresses with a specific domain and any subdomain for them? Or in other words, what am I doing wrong? How would you change postfix configuration to make it work?
This is an internal relay - not connected to the internet. The goal is to:
- Send emails with "from" addresses
*@domainB.comand*@*.domainB.comto a special relay dedicated to that domain (smtp.domainB.com), while: - Send everything else - to the default relay.
P.S. It's plain vanilla CentOS 7.7. Postfix 2.10.1. This /etc/postfix/relay_maps only works for the domain but not subdomains:
domainB.com [smtp.domainB.com]:25
.domainB.com [smtp.domainB.com]:25
(...and yes, I run the following after updating the file:
sudo postmap /etc/postfix/relay_maps
sudo systemctl restart postfix
)
P.P.S. Also, the following line was added to /etc/postfix/main.cf:
sender_dependent_relayhost_maps = hash:/etc/postfix/relay_maps
已采纳解答
原帖链接 · EchoMike444 · CC BY-SA 4.0
You have the option sender_dependent_relayhost_maps , this option is avalalabe since Postfix 2.3 .
So the option is avalaible on CENTOS 7
root@test-cs-7 ~]# rpm -qa postfix
postfix-2.10.1-9.el7.x86_64
[root@test-cs-7 ~]# postconf | grep ^sender_dependent_relayhost_maps
sender_dependent_relayhost_maps =
A very simple example :
add this section at the end of /etc/postfix/main.cf
sender_dependent_relayhost_maps = pcre:/etc/postfix/sender_dependent_relayhost
create a file /etc/postfix/sender_dependent_relayhost with this content :
/^boss@example\.com/ [192.168.8.2]
/^boss@example\.net/ [192.168.8.1]
/^.*@.*\.example\.com/ [192.168.8.3]
/^.*@.*\.example\.net/ [192.168.8.4]
/^.*@example\.net/ [192.168.8.2]
/^.*@example\.com/ [192.168.8.1]
/^.*@example\.net/ [192.168.8.2]
About option :
About prce table :
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
