Skip to content

ede1998/autoarchive

Repository files navigation

AutoArchive

AutoArchive is a simple Thunderbird addon that adds a button to mail views. If pressed the mail is archived to the preconfigured folder.

AutoArchive runs user provided javascript. You have been warned!

Configuration

The addon can be configured via the options tab. You can also import/export the settings there. As of now, the only settings are the rules for which mail has to be archived into which folder.

A rule consists of 2 values:

  • path determines the destination folder for a mail to be archived to. It has the following form: account_name/path/to/destination/folder. Path supports substitution of the current year: ${year} is replaced with the current year, e.g. 2021.
  • selector is a JS function body that receives message as an argument of type MessageHeader and returns a boolean. The selector function is executed to determine whether a particular mail is affected by a rule.

An example configuration might look like this:

[
    {
        "path": "john.doe@example.com/Archives/${year}/amazon",
        "selector": "return message.author.includes('@amazon.de');"
    },
    {
        "path": "john.doe@example.com/Archives/paypal",
        "selector": "return message.author === '\"service@paypal.de\" <service@paypal.de>';"
    },
    {
        "path": "Local Folders/Trash",
        "selector": "const author = message.author.replace('@', '@@'); return author === 'SpamBot <spam@@bot.example>';"
    }
]

FAQ

Doesn't Thunderbird offer an archiving feature out of the box?

Yes but, as far as I know, it is limited. You can only put your mails into a basic archive folder split into years. If you want more specialized folders, you're out of luck.

There is no archiving button on my mail.

Please make sure there is an archiving rule that applies to this mail.

There is no archiving button on my mail and I am sure that I made a rule for it.

Maybe the rule doesn't match the mail because some field has a different value than you expect. I noticed this behaviour when doing an exact match for the author field. Thunderbird hides the quotes wrapping the author name. To check if this might be the case for you, you can check the values in the raw mail (More > View Source).

Why does AutoArchive run user provided javascript? Isn't that totally unsafe?!

Yes it probably is. However the addon is mostly for myself and just passing a JS function as selector was way easier than implemented some kind of filter system.

Attributions

Icon made by Freepik from www.flaticon.com.