MBF Knowledge Base

I'm trying to allow my Postfix server to act as a relay for other mail domains, but it's not working. I'm receiving the following error: 554 5.7.1 Relay access denied. How do I fix this?

To allow your server to act as a relay for other mail domains, you need to have three different pieces in place.

First you need to tell Postfix that it is responsible for the domain(s). That is normally done in the virtual_mailbox_domains option, for example:

virtual_mailbox_domains=/etc/postfix/virtual_domains.txt

In /etc/postfix/virtual_domains.txt you would list the domains, 1 per line:

example.net
domain.com

Then you need to tell Postfix that the final destination is not the local machine, which is done in the transport table:

example.net smtp:[1.2.3.4]
domain.com smtp:[mail.domain.com]

The transport table can be configured in many ways, reading the documentation is advisable to find the best solution to your situation. The examples I have posted uses [] around the final destination, to exclude MX lookups.

Finally, you will need an MX record for the domain you want to relay for, pointing to your mail server.