接受一个域的所有邮件(从任何地方),将选定收件人的邮件转发到特定的地址,将所有其他邮件转发给特定的主机

我想要做的是build立一个sendmail服务器,接受所有人的邮件到一个特定的域名(比如example.com ),然后定义一个收件人列表,把这个邮件发送到指定的第三方地址上,一个特定的IP地址。

我试过这个:

 [root@splitter mail]# cat relay-domains example.com [root@splitter mail]# cat virtusertable [email protected] [email protected] 

并且大部分域的转发工作正常 – 它被传递到由example.com的MX指定的example.com – 但exception( [email protected] )被忽略

我试过这个:

 [root@splitter mail]# cat local-host-names example.com [root@splitter mail]# cat mailertable example.com esmtp:[1.2.3.4] [root@splitter mail]# cat virtusertable [email protected] [email protected] 

然后exception邮件正确分离,但其他任何用户在本地弹回( User unknown )。 我已经尝试添加到virtusertable

 @example.com %[email protected] 

但(可能并不意外),这导致rewrite: excessive recursion (max 50), ruleset canonify错误。

我更喜欢基于sendmail的解决scheme,因为我可以很快尝试这些解决scheme。 如果我没有得到任何好运,我会打开这个到其他MTAs。 如果任何人有任何想法如何做到这一点,我真的很感激他们。

让我们试试这个:

 # Assuming example.com is in $=w LOCAL_RULE_0 Ruser1 < @ example.com. > $* $@ newuser1 < @somewhere.com. > Ruser2 < @ example.com. > $* $@ newuser2 < @somewhereelse.com. > R$* < @ example.com. > $* $#esmtp $@ [1.2.3.4] $: $1 < @ example.com. > $2 

当然,如果你想让10个以上的用户都能使用,而且你需要使用地图工作,那么这个规模并不会很好,但是我从2014年5月起就不再担任邮局主pipe了,而且我有点生疏了。 如果你喜欢,我可以使用外部地图工作。

一如既往的记住,在你的sendmail.mc ,规则的左边是用制表符分隔的,而不是空格,所以不要复制粘贴 。 另外请记住重build你的sendmail.cf然后使用sendmail -bttesting:

 > 3,0 [email protected] 

如果所有按预期工作重新启动sendmail。