Some email services (Spectrum/TWC/Road Runner, Yahoo!, etc.) allow forwarding but not automatic deletion of forwarded email, leading to potential quota exceedance over time.
This Python script* can be scheduled or run manually to batch delete all messages in the Inbox:
#!/usr/bin/env python import imaplib M = imaplib.IMAP4_SSL("imap.example.com") M.login("firstname.lastname@example.org","password") M.select("Inbox") typ, data = M.search(None, 'ALL') for num in data.split(): M.store(num, '+FLAGS', '\\Deleted') M.expunge() M.close() M.logout()
Under iOS, use a-Shell (App Store | GitHub) to edit and save the script (e.g., "emptyinbox") in vim, then set as executable (
chmod +x emptyinbox). Run simply as
emptyinbox or pair with Shortcuts (specifying the full path, /private/var/mobile/Containers/Data/Application/long-string/Documents/emptyinbox) and add an icon to the Home screen via the Action icon.
See also Batch delete all email from POP server via Python.
* H/T codersofthedark, the imaplib documentation, and the participants in this discussion.
/misc | Jul 03, 2020
Subscribe or visit the archives.