I've been a Proton Mail user for a few years now. I love the fact that I'm not sharing my personal data and communication with advertisers. They're not able to track my communication and incoming emails to target ads. Though the service is good at what it does, it misses some bells and whistles on email management tools.  

Security and Privacy does have some drawbacks in ease of use! I used to have going on Gmail a script that would go through my email and automatically expire certain types of emails like newsletters, OTP emails, and Ecommerce order confirmations that were more than 15 days old. Unlike conventional email providers, ProtonMail doesn't have a way for my custom scripts to access my mailbox and purge these emails. They do have a desktop app that emulates IMAP connections, but I don't want a script on my laptop to do this work.

Here's how I perform my email management on ProtonMail using a feature called Sieve filters.  

Sieve Filters

Sieve filters on ProtonMail allow you to run rules that you can program on incoming emails before they hit your email box.

You can create and manage your Sieve rules in the Settings section of ProtonMail under Filters. When you want to create a new Sieve, choose the Add Sieve Filter option under Filters.

Sieve Filter Option on ProtonMail

You can choose a name for the Filter and edit the code behind the filter to customize the delivery of the incoming mails. Please note that these rules work only on incoming mails and not mails that already exist in your email account.  

Now let's get down to creating these rules. Here's an example: If I want emails from Spotify to go to a folder called MailingLists, here's the rule I'd write:

require ["fileinto", "imap4flags"];

if address :is "from" "[email protected]"
{ 
    fileinto "mailinglists";
}

If I want these emails to be marked as read and moved to the MailingLists folder, I will modify the rule to this:

require ["fileinto", "imap4flags"];

if address :is "from" "[email protected]"
{ 
    addflag "\\Seen";
    fileinto "mailinglists";
}

Simple enough. Now how about adding multiple email addresses to the same rule? This is how you can do it:

require ["fileinto", "imap4flags"];

if anyof(
    address :is "from" "[email protected]", 
    address :is "from" "[email protected]",
    address :is "from" "[email protected]"
)
{ 
    addflag "\\Seen";
    fileinto "mailinglists";
}

One thing to note is the require ["fileinto", "imap4flags"]; line in the code. You'll need the right packages to get the actions and tests to work. There's a full list of the supported flags on the documentation page.

Auto Expire Rules

Now you can set a sieve rule to auto-delete emails from your mailbox by adding the action expire to your rules. You can choose after how many days you want these emails to remove themselves. So to expire in 15 days, you'd add expire "day" "15" to your rules.

require ["fileinto", "imap4flags","vnd.proton.expire"];

if anyof(
    address :is "from" "[email protected]", 
    address :is "from" "[email protected]",
    address :is "from" "[email protected]"
)
{ 
    addflag "\\Seen";
    expire "day" "15";
    fileinto "mailinglists";
}

Now, any emails from these senders sent to your ProtonMail address will automatically get set to expire in 15 days. You'll see a countdown of the expiry when you view the emails on the web interface.

Email Expiry Countdown on ProtonMail Web

One of the rules from the ProtonMail document I found useful is to automatically move emails from mailing list management by looking for the list-unsubscribe header or social networks looking at their appropriate headers. Here's how the rules can chain up

require ["fileinto","vnd.proton.expire"];

if exists "list-unsubscribe" {
	expire "day" "15";
	fileinto "mailinglists";
}
elsif anyof(exists "x-facebook", exists "x-linkedin-id") {
	fileinto "social";
	expire "day" "7";
}
elsif anyof(
	address: is "from" "[email protected]",
	address: is "from" "[email protected]"
) {
	expire "day" "15";
	fileinto "ecommerce";
}


Go crazy with your filters and rules!

One word of caution: There's no way currently to 'unexpire' these emails. I've reached out to ProtonMail about this, and they said that emails once set to expire cannot be changed. They mentioned a workaround is to forward that email again to yourself if you want to archive it.

Tweet out to me if you find this useful.