DEV Community

Robin Kretzschmar
Robin Kretzschmar

Posted on

Sorting mails via IMAP - which language / packages?

Background story

I have a couple of mailboxes to manage because I created dedicated mail accounts on my own domain for shopping, newsletters and other stuff to simplify the management and make accounts a bit more secure.
To manage all the mailboxes, I use Thunderbird on Windows clients and Evolution mail on linux clients.

The idea

Even Thunderbird and EvolutionMail have good ways to filter messages, I want to be more in control and want to write a little script to define criteria to filter and move messages to folders. I already started such a project with Python and the IMAP library some time ago but lost the interest to handle all the cases with storing flags and stuff.

Requirements defined

The following should be possible:

  • Authenticate on IMAP Server via SSL
  • Fetch available folders
  • Fetch messages in folders
  • Get stats for messages (flags, read/unread, junk, etc.)
  • Set stats for messages (flags, read/unread, junk, etc.)
  • Move messages to different (existing) folder


The goal is to have as less effort as possible.

So which library / packages / approaches would you recommend for this type of project?

Top comments (1)

darksmile92 profile image
Robin Kretzschmar

Since no one has posted another idea, I will stick with the python3 standard IMAP library until new ideas come up.