Today I ran across this issue. You open Mail on your Mac running Lion with any IMAP email accounts (Gmail, Yahoo, Thirdparty server) and Mac Mail randomly deletes the email messages after it fetches new mail. You can verify this issue by shutting down your Mail app and viewing that messages in fact exist on the IMAP server. Then you open Mail and the emails are deleted as soon as the check activity is complete. There are no filters or rules running behind the scenes.
A ton of people on this thread on the Apple website are discussing and running into the same issue.
There are apparently 2 ways to fix this issue:
The first one is to simply disable “Use IDLE command if the server supports it” from the Advanced settings for your Account, as shown above.
The second fix is to wipe out all your emails and accounts and start all over. This method is pretty risky and I don’t think you should try it unless you really know what you’re doing. To do this, quit Mail, then using Terminal, move all the files in ~/Library/Mail/V2/ out into another location. Then Open Mail and recreate all your accounts.
Side note regarding Gmail and Priority Inbox
Personally I ran into this disappearing mail issue with Lion when I realized that Gmail was assigning some emails the Important Label without me knowing it. These emails were also skipping the Inbox. So basically, anything the Google deemed “Important” was never being show to me in Mail. How ironic right? The fix was to go into the Inbox settings in Gmail and Set these options:
Inbox Type: Classic (The Priority Inbox drives me insane personally)
Importance Markers: Show Markers (I tried using the No Markers option but it was causing the emails not to appear in my Mac Mail Inbox)
Filtered Mail: Override Filters (Again this option is here to leave messages in your inbox)
And finally in Lion Mail make sure to disable the IDLE option for the account.
Having done all this, I still don’t fully trust that Gmail is not putting things in the Important folder, so I have turned on the Show in IMAP feature for that label in Gmail Settings and check that folder once in a while in Mail.
I am using Mail Version 5.1 (1251/1251.1) for your reference.
Let me know if you are having similar issues with either Gmail Importance mail disappearing or Lion Mail deleting emails automatically.