Can you delete emails with imaplib? If so how?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the store method (of the
IMAP4object representing your connection) to set ther'\Deleted'flag on the message number you want to delete, as the example in the docs show; then the expunge method to actually perform all deletions so marked.Gmail’s implementation of IMAP has subtly different semantics, by default, but if you want you can tweak it to behave much more like a traditional IMAP implementation (where the above sequence works) — basically you have to enable the “Advanced IMAP Controls” lab, then follow the instructions at the URL I gave to get exactly the IMAP semantics you desire (physically deleting rather than archiving “deleted” mails, waiting or not for
expunge, and so forth).