I have two postfix instances on the same machine (Ubuntu 18.04) managed with postmulti. One instance accepts incoming mail from MUAs and from other mailservers on the internet. Mail is delivered to mailboxes with virtual_mailbox_maps and aliases are defined in virtual_alias_maps and also virtual_mailbox_domains is configured.
What I want to do: if a mail is not delivered to a mailbox, but an alias points to another domain not hosted on this machine, the external delivery should be done by the other postfix instance. How can I do that?
The reason is, that I want to deliver detected spam (by spamassassin in an after-queue inspection) to mailboxes (moved to the Junk folder by a sieve script, that works already), but I do not want to relay spam to external domains. So I want to use header_checks on the outbound postfix instance to discard those mails.
UPDATE:
I think I figured it out: in the main.cf of the inbound instance I configured
relayhost = [localhost]:10026
and in the master.cf of the outbound instance
127.0.0.1:10026 inet n - n - - smtpd
Is that the correct way to do it?