Advanced Mail Filtering RulesIf the basic spam config options are not enough for you, consider using JTAN's Advanced Mail Rule Editor available from the Mailbox Configuration page. It's very cool, very powerful. It's also not for everybody.First of all, it requires some study and consideration in order to generate consistent and useful rules. By way of trying to help, we will prevent you from entering totally inconsistent rules. Unfortunately, a picky interface is something that drives impatient beginners nuts, sending them off on rants about "annoying" and "hard to use". Moreover, you can most definitely cause yourself extreme confusion and lose mail, or worse, if you use these advanced rules carelessly. Please don't venture any further unless you agree to hold JTAN harmless for mistakes you might make. On the other hand, with these rules you can achieve far finer control than you can with the simplified controls. We do encourage you to use these rules if you can think, and if you can take responsibility for your choices. How it WorksYour basic configuration still operates, flagging messages based on their score. Advanced rules are then applied. Each rule specifies a conditional decision on some email header or other item. Rules are evaluated in the order given. If the condition is true for the selected item, the action is taken. Normally, if the action "delivers" or "deletes" the mail, no further rules are checked.Simple ExampleSuppose you never want to see any email with the word "viagra" in the subject line. Suppose you are certain that nobody would ever send you legitimate email with that word in the subject. It's easy to make a rule that would delete this mail. Here's what the rule looks like this:Let's study the components of the rule from left to right. First we have the digit "1". That tells us this is the first rule in the sequence. If lower down in the list you have a rule that says "viagra" subjects aren't to be deleted, that rule is too late. The mail has already been deleted by the earlier rule. Sequence matters. After the sequence number, we have the "Item" we are examining. In this case it's the Subject of the email. Other options include the From or To addresses, any header, or numeric quantities like the size of the mail or the "spamness" score. The next two columns are the "not" checkbox followed by the "Condition". These two are used in combination with each other. The "Condition" decides something about the selected Item. In the above example, it is deciding if the Subject contains a certain word. Conditions typically have a parameter. In this case the parameter is the word we are looking for. Another example of a parameter would be with the condition "Less". You need to say what number the Item must be less than. The "not" checkbox will reverse the sense of the condition. For example, if we wanted to select all mail that did NOT have the word "viagra" in the subject, we would have checked the "not" box. Finally we have the action and the action parameter. This is what we should do if the rule was true. Since we have selected "Delete" for the action, there is no parameter. If we had chosen an action like "Forward", then we would have to specify the forwarding address. On the extreme right is a "Del" checkbox for deleting the rule. Don't confuse this button with the "Delete" action. More ExamplesHere's another example that demonstrates the "Flags" item, and the "Folder" action. Suppose you want all your spam sent to a special IMAP folder named "spam". Use a rule like this:With the "Flags" item, we can test to see if the message was called spam by the basic flagging configuration (or your private blacklist). Use the 'IsSpam' flag to make your rules work with the basic configuration. Here are some other important points to keep in mind when you save to an IMAP folder. First of all, the folder needs to be created before this will work. Add the folder using your email program. MS Outlook will do this if you have set up your mailbox to use IMAP. You can also add IMAP folders with webmail. Remeber this is a folder on our server, not your PC, and is therefore, implicitly, a subfolder of your INBOX at JTAN. You don't need to use the INBOX prefix, just the name of the folder. Inbox sub.sub folders are not currently supported by advanced rules. Another possible use for a folder is to save larger messages. This is
handy when you normally check your mail with a handheld or a dialup
modem that doesn't have a lot of speed. You can have large messages sent
to a special "bigmail" folder using this rule.
Regular Expression ExampleRegExps are very powerful tools. Books have been written about them. Before you die, you owe it to yourself to learn about them. Here is a link to a decent tutorial. A web search will turn up thousands of references.In the JTAN rule editor, we use procmail compatible "minimal match" regular expressions. There's only one twist. A ^ character at the begining, and a $ at the end are implied. You shouldn't use them. The regep is pinned to the ends by default. Instead, if you DON'T want a forced match of the whole string, use .* wildcards at the ends.
The following is an example that uses regular expressions. The idea is
to delete mail with the word "viagra" in the subject, even if spammers
might stick odd characters between the letters, like "v|i|a|g|r|a" or
"v_iagra". The question mark wildcard allows 0 or 1 characters to match.
Subject: Come via grandma's favorite road.So you need to be careful, or expect some lossage. That's why we don't usually recommend the "delete" option unless you are certain you don't mind losing mail. Match ReplacementThe regular expression condition supports the procmail-style \/ match separator. If you use the special code \/ in your regexp, and if the regexp matches the item (ignoring the \/ code), then everything to the right of the \/ will be stored in the __MATCH__ variable and available as a string replacement in the action parameter.For example, if you use a regexp pattern like this X-SaveFolder: \/[a-z]+and you choose the "Folder" action, with parameter __MATCH__, then if you receive mail with a header X-SaveFolder: stuff, then that mail will be stored in an IMAP folder "stuff", assuming it exists. Other possible uses for this __MATCH__ replacement include dynamic remailing and forwarding, dynamic subject tagging, and other tricks. The use of __MATCH__ replacement in an action is very powerful, but it can also be hazardous. Make sure that your regexp is sufficiently restrictive so that the action is held in check. Also, it should be noted that to the right of the \/, maximal regexp matching is performed, which is usually what you want. Applying a Set of Rules to All MailboxesIf you want to apply a set of rules to any email coming in to any of your mailboxes, the way you do that is you pick one of your mailboxes to have your "master" rules. Then, in all your other mailboxes, you put just one rule with the "Include" action to include the rule set from your master.The "Include" action Includes the rules from the mailbox given in the parameter. Rules are always included, so there can be no Item or Condition. Only one level of include recursion is permitted. Processing continues with the next rule in the current mailbox after the include, assuming none of the included rules delivered the mail. | |||
Services | Resources | Contact | News | Members | Signup
|