Aug-15-2022, 10:14 AM
(Aug-15-2022, 04:24 AM)Linh_lee Wrote: Section to search emails from specific_username@*.* from any domain, in all folders, and delete them.For easier search of specific username look at(install) imap_tools
pip install imap-toolsA example i found.
from imap_tools import MailBox, A with MailBox('imap.mail.com').login('[email protected]', 'pwd', 'INBOX') as mailbox: # DELETE messages that contains '[email protected]' in body from INBOX folder mailbox.delete(mailbox.fetch(A(body='[email protected]')))Look at search-criteria.