postfix中继邮件dynamic

是否有可能使用postfix的relayhostdynamic地转发传入的电子邮件

 relayhost = proxy:mysql:/etc/postfix/email2server.cf 

我用mysql数据库来查询每个电子邮件与中继主机。 但没有工作。 如果我静态定义relayhost = myhost2.tld它会起作用。

我这样做完全错了吗? 什么是实现这一目标的正确方法?

提前感谢任何答案。

您不能使用SQL查找作为relayhost参数。 请参阅postconf 手册页man 5 postconf :

 ... relayhost (default: empty) The next-hop destination of non-local mail ... 

中继依赖收件人的电子邮件地址,你必须在你的后缀configuration中定义transport_maps参数。 在你的情况下,这看起来像这样:

 transport_maps = proxy:mysql:/etc/postfix/email2server.cf 

transport_maps覆盖默认的relayhost设置。 在man 5 transport中查看postfix期望的SQL查询结果。