指定后缀实例发送出站电子邮件

我有一台CentOS 6.5服务器运行Postfix 2.6x(默认发行版),绑定了五个公共IPv4 IP地址。 每个IP分别设置DNS和rDNS。 每个在不同的域使用不同的主机名。 我有五个Postfix实例,一个绑定到每个IP,就像这个例子:

  • 192.168.34.104 red.example.com / etc / postfix
  • 192.168.36.48 green.example.net / etc / postfix-green
  • 192.168.36.49 pink.example.org / etc / postfix-pink
  • orange.example.info / etc / postfix-orange
  • 192.168.36.51 blue.example.us / etc / postfix-blue

我已经通过telnet到端口25testing了每个IP。使用正确的主机名正确回答和横幅。 所有这些实例都收到电子邮件,没有任何问题,并发送到正确的位置。 这个设置,减去最后的实例,已经存在了几年,并且工作。

但是我从来没有打算设置出站电子邮件来通过任何主要的实例, 没有必要。 现在,我需要从blue.example.us发送实际上离开该接口和IP的电子邮件,以便Received头文件显示blue.example.us作为发送邮件主机,以便SPF和DKIMvalidation等。

从blue.example.com发送的电子邮件是由服务器上的单个shell帐户(account5)发送的反馈循环,该帐户专用于发送此电子邮件。 该帐号接收来自其他networking服务器的反馈电子邮件,保存这些电子邮件的正文,然后生成一个新的出站电子邮件标题,追加保存的主体,并发送电子邮件。 它通过将每封电子邮件发送到sendmail -oi -tsendmail -oi -t 。 我们这样做是为了掩盖初始服务器的身份。 处理这些电子邮件的procmail脚本正常工作。

但是,我无法将此帐户configuration为通过适当的Postfix实例/ IP /接口发送电子邮件。 完全相同的帐户和脚本通过主要Postfix实例/ etc / postfix发送电子邮件没有任何问题。 当我更改MAIL_CONFIG指向/ etc / postfix-blue在.bash_profile或处理此电子邮件的Procmail脚本,但是,我得到此错误:

 sendmail: fatal: User account5(###) is not allowed to submit mail 

我已经阅读了Postfix.org上的手册,search了Google,并在ServerFault.com上的三个以前的答案中尝试了这些build议:

Postfix – 指定接口发送出站邮件

Postfix用户不允许提交邮件

Postfix拒绝php邮件

在每次configuration更改之后,我都小心地停止并重新启动Postfix,并testing结果。 没有任何工作。 主要的postfix实例很高兴地接受来自account5的出站邮件。 postfix-blue实例继续拒绝来自account5的邮件,上面的sendmail错误。

虽然这是诱惑机器敌意的诱惑,但我知道我必须错过某些东西或做错事情。 有人可能会有什么build议吗? 如果您需要,请随时索取有关我的设置的更多信息。

= – = – = – = – = – = – = – = – = – =

在响应者的请求下,main.cf和master.cf用于a)主后缀实例(“red.example.com”)和b)FBL实例(“blue.example.us”)

[注意:以下未指定的所有参数都保留在默认的Postfix 2.6设置中]

主要:

master.cf

 smtp inet n - n - - smtpd 

main.cf

 myhostname = red.example.com mydomain = example.com inet_interfaces = $myhostname, localhost inet_protocols = all lmtp_host_lookup = native smtp_host_lookup = native ignore_mx_lookup_error = yes mydestination = $myhostname, localhost.$mydomain, localhost local_recipient_maps = mynetworks = 192.168.34.104/32 relay_domains = example.com, example.info, example.net, example.org, example.us relayhost = [192.168.34.102] # Separate physical server, main mailserver. relay_recipient_maps = hash:/etc/postfix/relay_recipients alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases smtpd_banner = $myhostname ESMTP $mail_name multi_instance_wrapper = ${command_directory}/postmulti -p -- multi_instance_enable = yes multi_instance_directories = /etc/postfix-green /etc/postfix-pink /etc/postfix-orange /etc/postfix-blue 

FBL:

master.cf

 184.173.119.103:25 inet n - n - - smtpd 

main.cf

 myhostname = blue.example.us mydomain = blue.example.us <= Deliberately set to subdomain only. myorigin = $mydomain inet_interfaces = $myhostname lmtp_host_lookup = native smtp_host_lookup = native ignore_mx_lookup_error = yes mydestination = $myhostname local_recipient_maps = unix:passwd.byname $alias_maps $virtual_alias_maps mynetworks = 192.168.36.51/32, 192.168.35.20/31 <= Second IP is backup MX servers relay_domains = $mydestination recipient_canonical_maps = hash:/etc/postfix-blue/canonical virtual_alias_maps = hash:/etc/postfix-fbl/virtual alias_maps = hash:/etc/aliases, hash:/etc/postfix-blue/canonical alias_maps = hash:/etc/aliases, hash:/etc/postfix-blue/canonical mailbox_command = /usr/bin/procmail -a "$EXTENSION" DEFAULT=$HOME/Mail/ MAILDIR=$HOME/Mail smtpd_banner = $myhostname ESMTP $mail_name authorized_submit_users = multi_instance_name = postfix-blue multi_instance_enable = yes 

**testingMasegaloeh的最新build议后的其他信息**

我刚刚尝试将“account5”添加到authorized_submit_users,并将.bash_profile中的MAIL_CONFIG设置为“account5”shell帐户,同时设置了“export MAIL_CONFIG”。 Procmail不再抱怨; 它认为它正在生成和发送FBL。 但是,maillog报告如下:

 May 29 14:47:42 newton postfix-blue/qmgr[3522]: 5BC773E612F: from=<[email protected]>, size=1106, nrcpt=1 (queue active) May 29 14:47:42 newton postfix-blue/qmgr[3522]: warning: connect to transport private/smtp: Connection refused May 29 14:47:42 newton postfix-blue/error[3766]: 5BC773E612F: to=<[email protected]>, relay=none, delay=0.01, delays=0/0/0/0, dsn=4.3.0, status=deferred (mail transport unavailable) 

我需要添加一些东西到传输configuration文件,也许?

当您通过本地提交邮件发送电子邮件(又名sendmail ,它将使用默认实例,例如red.example.com 。 这个行为在postfix官方文档中有解释。

一个Postfix实例是特殊的:这是其configuration目录是编译到Postfix实用程序中的默认实例。 默认configuration目录的位置通常是/ etc / postfix,可以通过“postconf -d config_directory”命令查询。 我们把这个configuration目录的实例称为“默认实例”。

默认实例负责本地邮件提交。 sendmail(1)本地提交程序使用setgid postdrop(1)实用程序将消息假脱机到默认实例的队列目录的maildrop子目录中。

即使在极less数情况下,使用“sendmail -C”将本地邮件提交到非默认的Postfix实例中,出于安全原因,postdrop(1)将查询默认的main.cf文件以检查所请求的non-默认configuration目录。

所以,在大多数其他方面,所有实例都是相同的,默认实例是“比其他实例更平等”。 您可以select创build额外的实例,但您必须至less有默认实例,其configuration目录位于默认编译位置。

一些build议:

  1. 基于上面的代码片段,您可以尝试使用sendmail -C来指定提交电子邮件的实例。 要么
  2. 另一个解决方法是交换实例,例如red.example.com变成blue.example.us ,反之亦然。

根据下面的评论进行编辑

 sendmail: fatal: User account5(###) is not allowed to submit mail 

authorized_submit_users参数引起的上述错误为空(postfix-blue实例)。 效果是没有人可以通过postfix-blue实例执行sendmail 。 将account5添加到该参数应该可以解决问题。

另一个错误

 warning: connect to transport private/smtp: Connection refused 

是由master.cf中缺lesssmtp传输引起的。 确保master.cf中存在这一行

 smtp unix - - n - - smtp 

并在该行的末尾添加-o smtp_bind_address = 192.168.36.51 ,这样电子邮件将通过地址192.168.36.51发送。