Depends on whether you are using IMAP or POP3.
For IMAP, the default is to detect messages being deleted, one by one.
For POP3, there is a setting under the account's Options and Folder (in Extended mode, top item) to "Purge when server empty".
This will purge all messages from the app if it finds that the sever has zero message. Something that would be the case if your desktop mail app is configured to delete all messages after checking mail.