I found a solution for my case.
What is the problem
On my iPhone, deleted emails disappear as expected, and the Mail app reflects this. However, on my iMac, these emails remain in the inbox.
Even after updating to iOS 18.2, the issue persists and remains frustrating.
My Solution
I decided to reset all my mailboxes (IMAP accounts) on my iPhone and start again scratch as follows:
1) Delete the IMAP account.
2) Fully shut down the iPhone.
3) Restart the iPhone.
4) Set up the IMAP account again.
5) Keep the default settings for folders (Drafts, Junk, Sent, Trash) on the server (not locally on the iPhone).
6) Testing successfully – everything works fine and continues to do so.
However …
7) Changing the special folders to be stored on the iPhone instead of the server caused problems.
8) Tests unsuccessfully ! I found that emails deleted on the iPhone no longer synced with the server. They disappeared from the iPhone but remained on the server.
Conclusion
iOS 18.x is working as expected only if the advanced folder settings (Drafts, Junk, Sent, Trash) are set to "on the server". If these folders are set to "On my iPhone", the server does not sync changes made on the iPhone.
I hope this can help someone facing the same issue.
My environment
iPhone 13 mini, iOS 18.1 and now 18.2, Apple Mail
Third party UNIX hosting with dovecot IMAP server (no iCloud involved), Roundcube Webmail
iMac M1 macOS 14.7.1, Apple Mail
Apple please
I would have the all years perfect working settings back. If I delete a message on the iPhone it should be deleted from the IMAP account, also if the Trash is set to be on the iPhone. Otherwise (e. g. holiday) if I manage mails for a longer time just on the iPhone, a) the account gets to its quota and b) being back on my iMac I have to delete every single message again.