Created
January 22, 2021 21:46
-
-
Save exander77/898f1291e8d939b068a97d01d7724d7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require ["include", "environment", "variables", "relational", "comparator-i;ascii-numeric", "spamtest"]; | |
require ["fileinto", "imap4flags"]; | |
# Stop processing for outbound emails | |
if address :all :comparator "i;unicode-casemap" :matches "From" ["username@protonmail.ch", "username@protonmail.com", "username@pm.me", #"username@example.com"] { | |
stop; | |
} | |
# Discard addresses where localpart is not 3 | |
if not address :localpart :length "from" 3 { | |
discard; | |
} | |
# DKIM or SPF fail | |
if anyof( | |
header :contains "Authentication-Results" "dkim=fail", | |
header :contains "Authentication-Results" "spf=fail" | |
) { | |
fileinto "Tampered"; | |
} | |
# If Unsubscribe header is detected it is newletter | |
if header :matches "list-unsubscribe" "*" { | |
fileinto "\\Newsletters"; | |
} | |
# No SSL/TLS transport encryption | |
if header :is "x-pm-transfer-encryption" "none" { | |
fileinto "Exposed"; | |
} | |
# Mark emails that contain full anti-spoofing checks | |
if allof(header :contains "Authentication-Results" "dmarc=pass", header :contains "Authentication-Results" "spf=pass", header :contains "Authentication-Results" "dkim=pass") { | |
fileinto "Validated"; | |
} | |
# Mark internal ProtonMail emails as validated too | |
if header :contains "X-Pm-Origin" "internal" { | |
fileinto "Validated"; | |
} | |
# Mark emails that have attachments | |
if exists "X-Attached" { | |
fileinto "Attachment"; | |
} | |
# Make spam seen | |
if allof (environment :matches "vnd.proton.spam-threshold" "*", | |
spamtest :value "ge" :comparator "i;ascii-numeric" "${1}") | |
{ | |
addflag "\\Seen"; | |
keep; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment