Categories
Useful & Productive

Simple sieve script to move junk emails

Spammy emails are frustrating and if you are running your own email server, chances are, you might still be getting spammy emails in your inbox without it being redirected to the spam folder. This little sieve script can solve your problem. Essentially, it looks for the subject. If the subject contains certain terms, you can forward those emails to a certain destination.

We are using Poste.io which is a scalable email solution that you can host yourself. It has an option where it can prepend spammy emails with whatever string you set on the settings page. We set it to “*****SPAM*****“. Now, all we have to do is ask the sieve script to move those emails with that string to a folder of your choice. This is helpful because now my inbox isn’t crowded with ‘potential’ spam to look through early in the morning when I just want to get to the real deal. Hope it helps you. I also found some cool sieve scripts that do more than just move emails into specific folders. I’ll link them up under resources. Have fun 😉

Sieve script

require ["fileinto", "mailbox"];
if header :contains "Subject" "*****SPAM*****" {
    fileinto "Junk";
}

Resources

Number of useful examples
Easy sieve testing
Wiki on sieve
Some more examples

 

Leave a Reply

Your email address will not be published.