TIL: Filtering email with Protonmail
I’m subscribed to an email listserv. The problem is they’re always ending up in my ProtonMail spam folder.
ProtonMail offers only a very simple option in the UI for dealing with spam: An explicit allowed senders list, and a blocked senders list. For me, that doesn’t work because each email comes from a different sender in the listserv, and I don’t want to keep adding every person’s name.
However, ProtonMail actually does provide a very powerful scripting capability, if you’re willing to write some code. To get started, head to settings -> filter -> add filter
The UI lets you set some of the basic options – In my case I was able to filter based on the subject title. However, even after creating this filter (and telling it to move to a folder), it was still treated as spam!
This is where the scripting comes in. Go back to the filter setting page, and hit the “Edit Sieve” button, which lets you edit the underlying code
I was today years old when I found out that there’s a scripting language called Sieve which is explicitly designed for parsing emails. If you open up your filter, you’ll see something similar near the top of the code:
require ["include", "environment", "variables", "relational", "comparator-i;ascii-numeric", "spamtest"];
require ["fileinto", "imap4flags"];
# Generated: Do not run this script on spam messages
if allof (environment :matches "vnd.proton.spam-threshold" "*", spamtest :value "ge" :comparator "i;ascii-numeric" "${1}") {
return;
}
Ah, this explains the problem. If the message is marked as Spam, the filters don’t run. I’m surprised there’s no option in the UI to change this setting. However, if you remove the if condition, then the spam filter is bypassed for your rule.