POSTFIX :将所有域用户从 Postfix 服务器中继到 Exchange

POSTFIX :将所有域用户从 Postfix 服务器中继到 Exchange

我删除了我的帖子并重新创建了它,使其尽可能清晰。我是 Postfix 的新手。因此,我有一个 Postfix 服务器将邮件转发到我的 Exchange 2016 服务器。我希望允许所有域用户将电子邮件从 Postfix 服务器发送到 Exchange。

这是一个简单的工作情况(域 1 是本地域(活动目录),域 2 是外部邮件域):

[root@srv-relayhost ~]# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
compatibility_level = 2
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
header_size_limit = 409600
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
meta_directory = /etc/postfix
mydomain = domain1.com
myhostname = srv-relayhost.domain1.com
mynetworks = xx.xx.xx.xx/32, yy.yy.yy.yy/32, zz.zz.zz.zz/32, 127.0.0.0/8
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix/README_FILES
relay_domains = $mydestination
relayhost = xx.xx.xx.xx
sample_directory = /usr/share/doc/postfix/samples
sender_canonical_classes = envelope_sender, header_sender
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
shlib_directory = /usr/lib64/postfix
smtp_generic_maps = pcre:/etc/postfix/generic.pcre
smtp_header_checks = regexp:/etc/postfix/header_check
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_CApath = /etc/pki/tls/certs
smtp_tls_security_level = may
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.key
smtpd_tls_security_level = may
unknown_local_recipient_reject_code = 550


cat sasl_passwd
xx.xx.xx.xx [email protected]:mypasswd


cat generic.pcre
/[email protected]/ [email protected]
/[email protected]/ [email protected]
/[email protected]/ [email protected]

使用此文件重写标题

cat header_check
/^From: [email protected]/ REPLACE From: "srv"
/^From: [email protected]/ REPLACE From: "copieur"
/^From:[[:space:]]+(.*)/ REPLACE From: "${1}"

两个测试示例(由 Linux 机器制作,test.domain1.com)。

echo | mutt -s "OK" -e 'my_hdr From: SAVE_SWITCHS <[email protected]>'  -- [email protected]
echo | mutt -s "OK" -e 'my_hdr From: SAVE_SWITCHS <[email protected]>'  -- [email protected]

一切正常。

现在,我想要的是映射域 2 的所有用户以[email protected]允许他们发送电子邮件。

在 generic.pcre 中,我添加了最后一行

/.*@domain2.com/ [email protected]

但现在只有第二个测试有效()。我无法接收第一个测试的邮件。我只收到发送到域 1 的邮件。也许正则表达式不正确。所以我尝试使用脚本来填充我的通用文件echo | mutt -s "OK" -e 'my_hdr From: SAVE_SWITCHS <[email protected]>' -- [email protected]

rm -f /tmp/mail
ldapsearch -H ldap://xxxx -x -D '[email protected]' -w 'pass' -b 'dc=domain1,dc=com' -s sub "(&(objectCategory=person)(objectClass=user)(sAMAccountName=*))" mail | grep "mail:" | cut -d " " -f 2 > /tmp/mail
while read LIGNE
    do
    cat /etc/postfix/generic.pcre | grep $LIGNE
    if [ $? == 1 ]
        then
        echo "/$LIGNE/ [email protected]" >> /etc/postfix/generic.pcre
    fi  
    done < /tmp/mail
rm -f /tmp/mail
postmap /etc/postfix/generic.pcre
service postfix restart

但问题是一样的。我只收到发送到 domain1 的邮件。 [email protected]映射到 generic.pcre 中。当我删除此映射时,一切正常。 [email protected]是我的 Exchange 服务器的已知用户(主邮件地址)。您能帮助 domain2 的所有用户允许[email protected]他们发送电子邮件吗?谢谢。

答案1

我的错,我忘了sender_canonical_maps = regexp:/etc/postfix/sender_canonical_maps

这是解决方案:https://serverfault.com/a/674984/284549

如果该主题不相关,我可以删除它。

相关内容