我试图设置一个Postfix(2.11.4)configuration,以便它这样做:
这是一个部分main.cf:
mydomain = example.com inet_interfaces = all inet_protocols = all mydestination = $myhostname, localhost.$mydomain, localhost alias_maps = hash:/etc/postfix/aliases alias_database = hash:/etc/postfix/aliases relayhost = outbound.example.com allow_mail_to_commands = alias,forward,include allow_mail_to_files = alias,forward,include luser_relay = [email protected]
对于#1,服务器上为[email protected]生成的邮件会自动发送到“outbound.example.com”进行处理。 对于#2,我在/ etc / postfix / aliases中有这个,所以到“[email protected]”的消息可以通过Perl脚本来处理
robot: | "/usr/local/bin/robomail.pl"
到现在为止还挺好。 这是#3,给我麻烦。
请参阅此服务器用于运行域名masquerading打开的Sendmail。 而且这个服务器上还有一些应用程序(我不能控制它)发送电子邮件到“乔治”(例如),并期望服务器将其自动转换为“[email protected]”,然后获取路由到“outbound.example.com”交付。
我试图通过设置一个luser_relay指令来解决这个问题:
luser_relay = [email protected]
这种工作 – 当本地交付到“乔治”失败,Postfix将重写它到[email protected]
但是,如果“george”实际上是服务器上的有效帐户(即列在/ etc / passwd中),则Postfix将接受该邮件并将其发送到本地邮件目录,而不是重写地址并将其转发。
我可以通过制作另一个/ etc / postfix / aliases条目来解决这个问题:
george: [email protected]
但是,当服务器有几十个本地用户帐户时,这显然是不可扩展的,并且一直添加更多。 从文档中可以看出,对于/ etc / postfix / aliases,没有通配符。 否则,我会想要做这样的事情:
robot: | "/usr/local/bin/robomail.pl" *: *@example.com
Postfix有没有办法做到这一点? 接受邮件“机器人”,但转发所有其他的“outbound.example.com”交付(如有必要添加@ example.com)?
更新:一些postconf详细信息,以及在本地服务器上从“root”发送到“george”的消息日志:
myhostname = myserver.example.com myorigin = $myhostname masquerade_domains = Mar 23 14:07:26 myserver postfix/pickup[12851]: D2B4A4763D: uid=0 from=<root> Mar 23 14:07:26 myserver postfix/cleanup[19630]: D2B4A4763D: message-id=<[email protected]> Mar 23 14:07:26 myserver postfix/qmgr[29583]: D2B4A4763D: from=<[email protected]>, size=323, nrcpt=1 (queue active) Mar 23 14:07:26 myserver postfix/local[19632]: D2B4A4763D: to=<[email protected]>, orig_to=<george>, relay=local, delay=0.04, delays=0.02/0/0/0.02, dsn=2.0.0, status=sent (delivered to mailbox) Mar 23 14:07:26 myserver postfix/qmgr[29583]: D2B4A4763D: removed
从日志中, 域名伪装过程将发件人和收件人都重写为[email protected] 。 这个重写背后的罪魁祸首是myorigin和append_at_myorigin 。 作为后缀文档说
append_at_myorigin(默认:是)
使用本地提交的邮件,将string“@ $ myorigin”附加到没有域信息的邮件地址。 使用远程提交的邮件,请附加string“@ $ remote_header_rewrite_domain”。
注1:此function默认启用,不能closures。 Postfix不支持无域名地址。
注2:在Postfix 2.2版本中,消息头地址重写只有在满足以下条件之一的情况下才会发生:
- 该消息是通过Postfix sendmail(1)命令收到的,
- 该消息从与local_header_rewrite_clients匹配的networking客户端接收,
- 该消息从networking接收,并且remote_header_rewrite_domain参数指定一个非空值。
要在Postfix版本2.2之前获得行为,请指定“local_header_rewrite_clients = static:all”。
在你的configuration中,postfix追加$myorigin = $myhostname = myserver.example.com到george 。
由于$ myhostname(myserver.example.com)在mydestination中列出,所以postfix将尝试通过
alias_maps定义 如果用户不匹配这两个检查,电子邮件将反弹。 否则,电子邮件将被传送到本地邮箱。
从这个问题,看起来像你要重写乔治 – > [email protected],而不是乔治 – > [email protected]。 然后你可以改变参数myorigin成为$mydomain 。 在main.cf
myorigin = $mydomain