postfix stop sending mail locally for one exchange cloud email address

Hello,

I have a problem and i can’t fix it, so i ask help :wink:

I have a virtual server with email addresses working with postfix on virtualmin.

I bought a external exchange email address, so i changed config, everything is ok with DNS.

But when i try to send mail within my domain (so XXX@mydomain.com to the new exchange email address YYY@mydomain.com) , it sends it locally, so my exchange address never receive my mail.

can you tell me how to do ? I tried several changes on my /etc/postfix/main.cf but with no result.

I tried to add a transport/relay, but then, postfix doesn’t find anymore my virtual mail accounts, and i got errors like :

xxx.mydomain@mydomain.com (expanded from xxx@mydomain.com): User
unknown in virtual alias table

I really need your help, thank you !

Sound tricky. You my be able to do want you want by setting an email filter. Possibly redirecting all mail sent to your domain to another domain that does not know about your local domain so it will go out and find your outside exchange. It may not be the best way to do it.
See https://www.virtualmin.com/documentation/tutorial/how-to-create-email-filter-in-usermin
M

thanks for your answer. I’m not sure I explain well :

but it seems that when i add relay/transport to my main.cf, my virtual accounts are renamed and so the mailbox can’t be found (got the error “xxx.mydomain@mydomain.com (expanded from xxx@mydomain.com): User unknown in virtual alias table”)
and in my virtual, i got that line for example (with anothers) : xxx@mydomain.com xxx.mydomain

to simplify, i want the mail server to work as usual, except for a specific email address which is an exchange email address (but has the same domain).

Because if i send mail from my virtual domain, it doesn’t go to the exchange address (which is on the same domain). I explain :

If i try to send mail from XXX@mydomain.com to another ZZZ@mydomain.com , it works and send it localy via virtual server

BUT

If i try to send mail from XXX@mydomain.com to the exchange email address YYY@mydomain.com , i got this error “Recipient address rejected: User unknown in local recipient table’” ; of course because it is an exchange one now and is not anymore on my virtual server.

If someone can help me it would be so great, because i search answers since 2 days now, without any good one.

No one can help me ?

In fact, after multiple trys, i think my problem comes from my virutal accounts for mail (with virtualmins, that are renamed “xxx@domain.com” to xxx.domain") and transport file in postfix. Mails within my virtual domain are sent “locally”, and I want them to be sent over the MX, because i have a exchange email which is on an external server…

Can anyone tell me how to do ?