Creating Rules With FastMail to Filter More Spam

 

[User submitted]

In order to lock down Fastmail, you will need to do the following:

1) Log in to Fastmail web mail and select the “Mail” button in the top left and then select “Advanced”.
2) Select the “Rules” section.
3) Go to the bottom of this page and select “View filter source, click "Apply all changes" to save changes first (advanced users only)”.
4) You will see a sieve script based on your current rules. You will need to add the following rule after the line that reads "if not header :contains ["X-Spam-known-sender"] "yes" {
":

if not header :is ["X-Virus-Scanned"] "by MailRoute"  {
  if not exists ["X-Sasl-enc"] {
    fileinto "INBOX.Junk Mail";
    stop;
  }
}

If you have no other custom rules, the complete script should be as follows:

require ["envelope", "imapflags", "fileinto", "reject", "notify", "vacation", "regex", "relational", "comparator-i;ascii-numeric", "body", "copy"];

if not header :contains ["X-Spam-known-sender"] "yes" {
if not header :is ["X-Virus-Scanned"] "by MailRoute"  {
  if not exists ["X-Sasl-enc"] {
    fileinto "INBOX.Junk Mail";
    stop;
  }
}
if allof(
  header :contains ["X-Backscatter"] "yes",
  not header :matches ["X-LinkName"] "*" 
) {
  fileinto "INBOX.Junk Mail";
  stop;
}
if  header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["5"]  {
  fileinto "INBOX.Junk Mail";
  stop;
}
}

5) Select “Apply all changes” to save the script. If it was successful, you will be returned to the advanced settings menu page and it will say “Advanced rules saved” at the top of the page.

The rule checks for two things:
1) The mail header must contain "X-Virus-Scanned: by Mailroute"
2) Otherwise, it must have a header "X-Sasl-enc”. This will be present in any mail you send to yourself or from another Fastmail mailbox sent internally within the Fastmail system which is never routed through Mailroute.

Make sure to remove the 'junk mail' line from Fastmail's sieve rules. 

Contact sales@mailroute.net or support@mailroute.net for more information. 

888.485.7726

Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    Ernie Biancarelli

    Helpful article. As of 8/21/15, the default Fastmail rule for me was simpler than the listed example. Nonetheless, adding the header check for 'X-Virus-Scanned' and the Fastmail 'X-Sasl-enc' text works perfectly.

    If you don't want to see the mail at all, replace 'fileinto "INBOX.JunkMail"' with 'discard;'. That has the effect of silently throwing the mail away so it doesn't show up in a Junk Mail folder.

    Additionally, you can test your rules with the Fastmail Sieve Tester page (https://www.fastmail.com/cgi-bin/sievetest.pl).

  • 0
    Avatar
    Alexander Verbovetsky
    1. One more condition must be checked if there are pop downloads: not header :matches "X-LinkName" "*"

    2. The above procedure  requires making the sieve script custom, which is not always convenient. To avoid this, one can go to Advanced > Rules, then choose "Discard" or "File into folders" and create an Advanced rule with the condition

    allof( not header :is "X-Virus-Scanned" "by MailRoute", not header :matches "X-LinkName" "*", not header :matches "X-Sasl-enc" "*" )

  • 0
    Avatar
    MailRoute Support

    User Comment from Alexander V

    1. In addition to 2 conditions discussed in the article one has to

      check the existence of X-LinkName header to detect messages received

      from pop links.

    2. The article advises to enter the sieve rules via the Advance tab.

      This is very drastic change (as described in the documentation:

      https://www.fastmail.com/help/technical/sieve.html). Much better to use

      the "File into folders" tab with "Advance" choice in the "Message with"

      column and the following text in the "The text" column:

      allof( not header :contains "X-Virus-Scanned" "by MailRoute", not header

      :matches "X-LinkName" "*", not header :matches "X-Sasl-enc" "*" )

Please sign in to leave a comment.
Powered by Zendesk