postfix:捕获外发邮件并重定向

postfix:捕获外发邮件并重定向

我正在尝试配置我的 postfix,以便所有经过 tld dev 的邮件都将被重定向到 root 用户,这是我的配置文件:

[alexus@wcmisdlin02 postfix]$ tail -1 main.cf 
transport_maps = hash:/etc/postfix/transport
[alexus@wcmisdlin02 postfix]$ tail -1 transport
.dev    :redirect root
[alexus@wcmisdlin02 postfix]$ 

或者如果你想看完整个视频

[alexus@wcmisdlin02 postfix]$ 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
html_directory = no
inet_interfaces = localhost
inet_protocols = all
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.6.6/README_FILES
relayhost = uftwfmail
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
transport_maps = hash:/etc/postfix/transport
unknown_local_recipient_reject_code = 550
[alexus@wcmisdlin02 postfix]$ grep -v ^# transport
.dev    :redirect root
[alexus@wcmisdlin02 postfix]$ sudo postmap transport && service postfix reload
[alexus@wcmisdlin02 postfix]$ 

这是 tail -f maillog

May 19 17:01:21 wcmisdlin02 postfix/pickup[461]: 53C54201CDA: uid=0 from=<root>
May 19 17:01:21 wcmisdlin02 postfix/cleanup[513]: 53C54201CDA: message-id=<[email protected]>
May 19 17:01:21 wcmisdlin02 postfix/qmgr[462]: 53C54201CDA: from=<[email protected]>, size=442, nrcpt=1 (queue active)
May 19 17:01:21 wcmisdlin02 postfix/smtp[732]: fatal: valid hostname or network address required in server description: redirect root
May 19 17:01:22 wcmisdlin02 postfix/qmgr[462]: warning: private/smtp socket: malformed response
May 19 17:01:22 wcmisdlin02 postfix/qmgr[462]: warning: transport smtp failure -- see a previous warning/fatal/panic logfile record for the problem description
May 19 17:01:22 wcmisdlin02 postfix/master[1832]: warning: process /usr/libexec/postfix/smtp pid 732 exit status 1
May 19 17:01:22 wcmisdlin02 postfix/master[1832]: warning: /usr/libexec/postfix/smtp: bad command startup -- throttling
May 19 17:01:22 wcmisdlin02 postfix/error[598]: 53C54201CDA: to=<[email protected]>, relay=none, delay=1.1, delays=0.07/1/0/0.03, dsn=4.3.0, status=deferred (unknown mail transport error)

我已经尝试在传输中使用 FQDN

[root@wcmisdlin02 postfix]# tail -1 transport
.dev    :redirect [email protected]
[root@wcmisdlin02 postfix]# 

这是 tail -f /var/log/maillog

May 19 17:08:54 wcmisdlin02 postfix/pickup[1139]: 88565201D3B: uid=0 from=<root>
May 19 17:08:54 wcmisdlin02 postfix/cleanup[1162]: 88565201D3B: message-id=<[email protected]>
May 19 17:08:54 wcmisdlin02 postfix/qmgr[1140]: 88565201D3B: from=<[email protected]>, size=442, nrcpt=1 (queue active)
May 19 17:08:54 wcmisdlin02 postfix/smtp[1218]: fatal: valid hostname or network address required in server description: redirect [email protected]
May 19 17:08:55 wcmisdlin02 postfix/qmgr[1140]: warning: private/smtp socket: malformed response
May 19 17:08:55 wcmisdlin02 postfix/qmgr[1140]: warning: transport smtp failure -- see a previous warning/fatal/panic logfile record for the problem description
May 19 17:08:55 wcmisdlin02 postfix/master[1832]: warning: process /usr/libexec/postfix/smtp pid 1218 exit status 1
May 19 17:08:55 wcmisdlin02 postfix/master[1832]: warning: /usr/libexec/postfix/smtp: bad command startup -- throttling
May 19 17:08:55 wcmisdlin02 postfix/error[1143]: 88565201D3B: to=<[email protected]>, relay=none, delay=1.1, delays=0.11/1/0/0.02, dsn=4.3.0, status=deferred (unknown mail transport error)

答案1

您的 /etc/postfix/transport 无效。根据http://www.postfix.org/transport.5.html它应该包含类似

.dev   local:

那么所有发往 *.dev 的邮件都将发送到 @ 前面的本地部分指定的帐户。仅使用 transport_maps 无法将本地部分重定向到本地别名。

答案2

您可以尝试将 .dev 域名设置为后缀邮件转发域名使用虚拟传送机制,但我不确定它如何与假 TLD 一起工作。

答案3

Transports 用于告诉 Postfix 如何将消息发送到下一跳,而不是用于重写。您需要的是地址重写或别名。http://www.postfix.org/ADDRESS_REWRITING_README.html是一个很好的起点。根据您的设置,您可能能够使用通用地图,上述链接中也有详细说明。

例如,当否决 MX 记录或将域路由到其他服务器时会使用传输图,而不是当您想将一个地址更改为另一个地址时使用。

相关内容