postfix relay emails dynamically

Posted on

postfix relay emails dynamically – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, email, postfix, , .

Is it possible to relay incoming emails dynamically with postfix’s relayhost?

relayhost = proxy:mysql:/etc/postfix/

and I used mysql database to query each email with relay host. But did not work.
if I defined relayhost = myhost2.tld statically it works.

Am I doing this completely wrong? What is the correct way to achieve this?

Thanks for any answers in advance.

Solution :

You can not use a SQL lookup as relayhost parameter. See the postconf manpage man 5 postconf:

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

To relay depeding on the recipient email address you have to define the transport_maps parameter in your postfix configuration. In your case this would look like this:

transport_maps = proxy:mysql:/etc/postfix/

transport_maps overwrites the default relayhost setting. Look in man 5 transport to see what postfix expects as SQL query result.

Leave a Reply

Your email address will not be published.