I was having problems with deleting email messages when using my Iphone and an IMAP connection to read emails on my email (Qmail) server. Here is an explanation of what to do…. discovered it on this page:
The basic issue is that the settings on the phone need to match the settings on the email server. The problem is that the setting on the Iphone has the root directory for the mailbox as ‘/’, but it should be ‘INBOX’. Here’s how to change the settings on the Iphone….
On the Iphone, go to ‘Settings’, ‘Mail, Contacts, Calendars’,
select the email account that is causing the problem, and go into the ‘Account’ settings for that email address, Scroll down to the ‘Advanced’ settings, and select it…
Scroll down to ‘Incoming Settings’, and the the IMAP Path Prefix’ from ‘/’ to ‘INBOX’
Go back to Account, and touch the ‘Done’ button at the top right of the screen.
Note: Since you just changed the path to the mailboxes, you might need to go back into the Advanced settings and verify or change the various email folder settings (i.e. Sent, Trash, Junk, etc.) If needed, go back into the Advanced settings, select the folder (in this example, the ‘Drafts’ folder), it will then bring the following screen up. Select ‘Drafts’ under the ‘ON THE SERVER’ line. Do this for each of the corresponding folders in the email account (Sent -> Sent on the server; Trash -> Trash on the server; etc).
Once this is done, you will be synced properly for that email account on the server, on your iphone, and on your computer.