If you sign in with same Apple ID and password on the same network on iPhone and Mac the Apple ID should be example1@icloud.com " only " then the mails in inbox / sent will be synced .
The other method is https://support.apple.com/en-in/guide/mail/mlhlp1231/mac
If you create a mailbox under on my section and drag and drop the mails from inbox / sent those mails are already synced with iPhone , the best way is if there are mails from gmail move them to iCloud inbox .
Many users have different accounts set up like gmail , yahoo they have also created an Apple ID say example2@gmail.com
If an Apple ID say example2@gmail.com is signed in Mac and same in iPhone the mails will not be synced , however you can send mails from phone to Mac or vice versa to each other or other recipients .