Forward all emails from one domain to the same external domain (dont try to delivery internally)

Im trying to send emails from example@example.com from the MIAB server, to another email server with the @example.com domain. The MIAB server is setup with multiple domains (@example.com, @test.com). When I add the @example.com it doesn’t allow me to send any mail to the other email server (non MIAB @example.com server).

What Im looking for is a way to have all mail trying to be send to @example.com to automatically be sent to the other email server, it should never try to delivery internally. Does anyone know where this would be set at?

why though? just setup the MX to the other server…?

I still want to ability to receive and send mail to the other domain @test.com.

But @example.com should be forced to send to the other server.

It would be an unsupported modification within postfix. Is there some specific reason you need this specific setup for email routing? MiaB always sends via the Local Mail Exchanger by default rather than a Remote Mail Exchanger.

You can use the postfix transport_maps parameter.
I did something similar recently: some users from my domain are using GSuite and some are using MiaB.

@lucasxteixeira Do you have an example of the config on how you did this?

Add this to the file /etc/postfix/main.cf:

transport_maps = hash:/etc/postfix/transport_maps

Then create the file /etc/postfix/transport_maps containing the specific address (you can try the wildcard) and the server to send the emails:

user1@example.com smtp:aspmx.l.google.com
user2@example.com smtp:aspmx.l.google.com

After, run postmap and restart postfix:

postmap /etc/postfix/transport_maps
service postfix restart

1 Like

Please keep in mind that once you have made this type of modification you will be in unsupported territory … that said, you should be fine to do this however please note that the changes you make will most likely be overwritten by MiaB when it is upgraded in the future. So be prepared to make these modifications whenever you upgrade.

Thanks for the input, I will try the modifications recommended. Ill keep you posted if that works

I guess I have a similar scenario. I’m using MIAB to relay email sent by the ERP of one of our customers. Their own mailserver wouldn’t suffice.
Now, however when I’m mailing my customer MIAB is obviously trying to route it internally. Would I have to create a transport map as:

*@domain.com smtp:theirmailserver

Or am I interpretting this wrong?

According to the documentation that is the way to go.
I never tested it myself though.

Did it work, or no?? Are there any issues with being overwritten by MiaB updates? If so, how often - daily, or version upgrades?