Skip to content

IsmaheneLarbi/automatic_mail_deletion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

automatic_mail_deletion

Description :

Python script that deletes all emails with specified criteria.

  • A specific sender email sent after a certain date

Requirements :

For this script to work, you have to :

  1. Make sure imap is enabled in your account settings. For google, the provider I'll be using, here's how to enable imap if it isn't.
  2. Allow less secure apps such as this one to have access to your mail account. To do so, generate a specific password for this app. when asked for the name of the app, copy paste: automatic_mail_deletion

Test :

  1. To test if this works on gmail, write the following on the search bar:
    in:{folder you chose to delete from} from:{email of the sender} after:{first date to start deleting from}
    example:
    in:inbox from:[email protected] after:01/04/2022
  2. launch the script : python automate_mail_deletion.py
  3. Refresh your providers page

Further use :

  • If you want to change the folder you're selecting: imap.select('"folder of your choice"')
  • You can list all the folders using imap.list() before the select
  • If you want to change the criteria, change the second parameter of this instruction: imap.search(None, "FROM '[email protected]' SINCE '02-Jan-2022'")
  • You can look up the criteria on the imap library manual
  • You can look up the gmail search operators here.

Let's do this !

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages