在后缀我试图为未知的本地帐户设置一个通用地址。 任何可以传送给本地用户的邮件都应该被传送到本地邮箱(并且尊重/etc/aliases ,既包括本地别名,也包括将邮件转发到外部的别名)。 任何不在/etc/aliases或/etc/passwd的用户邮件都应该被redirect到root 。 对于root我已经在/etc/aliases设置了一个/etc/aliases来redirect到一个单独的邮件地址[email protected] (不在本地服务器上)。
为了达到这个我已经在main.cf设置:
luser_relay = root local_recipient_maps =
我尝试过的其他设置是luser_relay :
[email protected] root@localhost [email protected] root@--server hostname-- root@$local --other user with no alias-- --other user with no alias--@localhost --other user with no [email protected] --other user with no alias--@--server hostname-- --other user with no alias--@$local
但是我不断收到用户查找错误(使用mail -s test test向不存在的testing用户mail -s test test ):
Jan 4 14:08:03 test postfix/pickup[28595]: A4E3382454: uid=--uid-- from=<--local user--> Jan 4 14:08:03 test postfix/cleanup[29192]: A4E3382454: message-id=<20150104140803.A4E3382454@--server hostname--> Jan 4 14:08:03 test postfix/qmgr[28596]: A4E3382454: from=<--local user--@--server hostname-->, size=456, nrcpt=1 (queue active) Jan 4 14:08:03 test postfix/local[29194]: warning: error looking up passwd info for test: No such file or directory Jan 4 14:08:03 test postfix/local[29194]: A4E3382454: to=<test@--server hostname-->, orig_to=<test>, relay=local, delay=0.02, delays=0.01/0/0/0, dsn=4.0.0, status=deferred (user lookup error)
如果有一个解决scheme,其中设置了catch-all地址[email protected] ,但是我更喜欢将它redirect到root并且尊重/etc/aliaseses这样当我需要更改[email protected]我只需要在/etc/aliases而不是在另一个后缀configuration文件中。
我的后缀版本是2.10.1(CentOS 7)除了上面的luser_relay和local_recipient_maps我已经添加了recipient_bcc_maps和transport_maps 。
也许我的交通地图干扰了luser_relay ?
/.*@localhost(\.localdomain)?$/ local: /.*@--the server's hostname--/ local: /.*@--company domain-- relay: /.*/ discard:
交通地图的目的是提供任何本地邮件,允许邮件发送到公司域,但放弃任何其他邮件。 recipient_bcc_maps被设置为将在传输映射中丢弃的所有邮件设置为debugging地址。 同样, /etc/aliases中的root /etc/aliases落在--other domain to not discard-- 。 由于这涉及到一个开发服务器,我希望任何本地邮件都可以这样交付,并且还可以发送任何寄给公司域的邮件,但是防止任何其他邮件被发送到外部世界。
postconf -n的输出postconf -n :
alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases command_directory = /usr/sbin config_directory = /etc/postfix 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 html_directory = no inet_interfaces = localhost inet_protocols = all local_recipient_maps = luser_relay = root mail_owner = postfix mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man mydestination = $myhostname, localhost.$mydomain, localhost newaliases_path = /usr/bin/newaliases.postfix queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES recipient_bcc_maps = pcre:/etc/postfix/recipient_bcc sample_directory = /usr/share/doc/postfix-2.10.1/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop transport_maps = pcre:/etc/postfix/transport unknown_local_recipient_reject_code = 550
任何人都可以在我的configuration中发现错误?
谢谢!
这花了很长时间,但我终于find了问题。 它在NSSconfiguration/etc/nsswitch.conf 。 我的Rackspace Cloud Server默认安装了yum软件包sssd-client ,而/etc/nsswitch.conf有passwd和其他文件的默认项以使用sss 。
基本上如果你有默认的/etc/nsswitch.conf并且安装了sssd-client软件包,那么在CentOS 7上不会出现No such file or directory问题。这是因为它试图查找/var/lib/sss/mc/passwd最终在一个strace的帮助下计算出来,这也是一个很大的麻烦,以正确工作)。 但是当你没有设置sssd时,那个文件就不存在了。 我已经通过从CentOS网站下载CentOS 7 DVD并在VM中安装最小安装来testing。 接下来,我将luser_relay添加到了Postfixconfiguration中,但是我所做的只是安装了sssd-client ,并且“神奇地”停止了工作。
修复1:从/etc/nsswitch.conf删除sss 。
你会看到一行:
passwd: files sss
将其更改为:
passwd: files
默认情况下,为shadow , group , services和netgroup group启用了sss ,您应该删除它以防止在libnss尝试访问它们时出现问题。
修复2:删除sssd-client包。
删除sssd-client包也解决了这个问题,我猜是因为没有客户端libnss忽略/etc/nsswitch.conf的sss指令。 如果你不需要它,你可以用yum remove sssd-client将其yum remove sssd-client 。