configuration后缀捕获所有域的所有电子邮件,并转发给本地用户

我想configurationPostfix(在Ubuntu上)捕获所有域的所有电子邮件,并将它们存储在本地。

我会用它来testing。 被testing的应用程序将电子邮件发送到随机地址([email protected][email protected]等),我想在本地查看这些电子邮件(thunderbird)。

我现在已经在main.cf 中将anyuser @ mydestination转发到localuser:

local_recipient_maps= luser_relay = localuser 

但是我想将anyuser @ anydomain转发给localuser。

什么是最简单的Postfixconfiguration?

谢谢!

这是一个好的开始! 虽然可能还有其他方法,但我会继续从你开始的地方,即

 local_recipient_maps = luser_relay = localuser 

在这种情况下,你只需要把所有的domais都当作$mydestination

覆盖Postfix的内置默认transport:nexthop使用传输映射可以实现transport:nexthopselect:

transport_maps (默认值:空)

可选查找表,包含从收件人地址到(邮件传送传送,下一个跃点目的地)的映射。 有关详细信息,请参阅运输(5) 。

指定零个或多个type:table由空格或逗号分隔的type:table查找表。 表格将以指定的顺序search,直到find匹配。 如果对本地文件使用此function,则在更改后运行postmap /etc/postfix/transport

在你的main.cf ,添加transport_maps = hash:/etc/postfix/transport

/etc/postfix/transport结合这两个:

  • local_transport (默认: local:$myhostname

    这是使用mydestination最终传递到域的默认值,以及匹配$inet_interfaces$proxy_interfaces [ipaddress]目标的$proxy_interfaces 。 默认的nexthop目的地是MTA主机名。

  • * transport:nexthop

    特殊模式*表示任何地址(即,它充当通配符模式,并且对于Postfix传输表是唯一的)。

结果: * local:$myhostname

请保持这个非常规的configuration在你的实验室。

我发现另一个configuration工作:指定“mydestination”作为接受任何域的正则表。

Main.cf:

 local_recipient_maps= luser_relay = riskop mydestination = regexp:/etc/postfix/match_all_destination_re 

match_all_destination_re(//匹配所有内容,结果无关紧要):

 // this_can_be_anything 

我认为这个解决scheme比Esa的“Overriding Postfix的内置默认传输:nexthop”解决scheme更直接。

请注意,也可以使用perl兼容的“pcre”格式表来代替“regexp”表格格式。 这可能会导致更好的性能(这在我的使用情况中绝对没有关系)。 在这种情况下,你需要在Postfix中支持pcre。 在这种情况下的configuration:

Main.cf:

 local_recipient_maps= luser_relay = riskop mydestination = pcre:/etc/postfix/match_all_destination_re 

match_all_destination_pcre(//匹配所有内容,结果无关紧要):

 // this_can_be_anything