In a hybrid environment, Exchange on-premises emails will be sent from Exchange on-premises to Internet directly. Outbound messages to the Internet
Then, about sending email from command, I would suggest you relay email from Exchange online with 587 port. Because, you even could use a nonexistent email address to relay email successfully when using 25 port to relay email. It is different from sending email from mail client.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.