Relay access denied error attempting to setup relay to another SMTP server

I am attempting to setup 2 SMTP servers behind one firewall. One server for domainA.com and another for domainB.com. I want to configure the server for domainA.com to accept mail for domainB.com and forward it internally.

I have added the following setup in /etc/postfix/main.cf on domainA.com:

transport_maps =
    hash:/etc/postfix/transport
    proxy:mysql:/etc/postfix/mysql/transport_maps_user.cf
    proxy:mysql:/etc/postfix/mysql/transport_maps_maillist.cf
    proxy:mysql:/etc/postfix/mysql/transport_maps_domain.cf

relay_domains =
    $mydestination
    hash:/etc/postfix/relay
    proxy:mysql:/etc/postfix/mysql/relay_domains.cf

relay_recipient_maps = hash:/etc/postfix/relay_recipients

relay_transport = relay

And in the referenced files:

/etc/postfix/relay

domainB.com

/etc/postfix/relay_recipients

@domainB.com x

/etc/postfix/transport

domainB.com     smtp:[192.168.0.236]

I have run postmap on each of these files.

Mail to/from domainA.com works fine. When I attempt to send mail to [email protected], it bounces with 554 5.7.1 <[email protected]>: Relay access denied


Solution 1:

I noticed I had received an error when running postmap:

postmap: warning: /etc/postfix/relay, line 1: expected format: key whitespace value

I changed the file to contain domainB.com x and re-ran postmap. It appears mail is now being accepted for relaying!