Information Technology Services - Computing, Networking and Storage
Would you like to answer a few questions to help us improve our website?
Yes | No Thanks | Maybe Later

Creating Elm Filter Rules

Filter rules contain conditions run on an email received and the subsequent actions to take if an email matches a particular condition.

These rules are typically specified in the form:

if ([expression]) then [action]

An [expression] can be defined as:

  • A single condition: [condition],
  • A list of conditions: [condition] and [condition] and..., or
  • The negation of a condition or list of conditions: not [condition].
There are three types of conditions that a filter can use:
  1. A condition based on a header in the email. The format of these conditions is [header] [comparison] [value].

    The possible values of [header] are: from, to, sender (reply-to), and subject.

    The header [comparison] tests are: = (equal to, is), != (not equal to, is not), and contains (a part of). The [value] used in these conditions is a string, enclosed in quotation marks.

    For example, to use the condition where the sender of an email is ttrojan@usc.edu, the condition should be specified as:

    from = "ttrojan@usc.edu"

    To check that the recipient is not ttrojan@usc.edu, the condition would be:

    to != "ttrojan@usc.edu"

    To check that the Reply-to address is a USC email address, use the condition:

    sender contains "usc.edu"
  2. A condition can also be used that checks the number of lines in an email. This condition is specified as lines [comparison] [value].

    , where [comparison] is a relational operator (<, >, = , <=, >=, !=), and [value] is an integer value.

    For example, to test whether an email is less than 30 lines long, the condition would be:

    lines < 30

    , whereas to check that an email is greater than or equal to 1000 lines, the condition should be specified as:

    lines >= 1000
  3. The last condition is the always condition, which always passes the conditional test.

Once the filter finds a rule that passes the conditions in the expression, it can take several [action]s:

  • delete, which deletes the message completely.
  • save [foldername], which saves the message in the file defined by [foldername].

    Note: [foldername] must be the absolute path to the file for that folder.
  • savecopy [foldername], which saves the message in the file defined by [foldername] and leaves a copy of the message in the Inbox.

    Note: [foldername] must be the absolute path to the file for that folder.
  • forward [address], which forwards the email to the email address specified as [address].
  • forwardc [address], which forwards the email to the email address specified as [address] and leaves a copy of the email in the Inbox.
  • execute [program], which runs the program specified as [program] with the email message as its standard input.
  • executec [program], which runs the program specified as [program] with the email message as its standard input and leaves a copy of the message in the Inbox.
  • leave, which allows the message to be delivered normally to the Inbox.

The order of the rules does matter when you are specifying filtering rules. The filter will examine the rules until it finds one where the condition evaluates positively and run the action for that rule only. Any subsequent rules will be ignored for that message.

For examples, see the Elm Examples page.

Help

The Customer Support Center can assist you with setting up filters for your mail. However, consultants will not extensively troubleshoot filter rules, nor will they assist users who need finer rules than Elm filters allow or who need to get a specific program to work--either as part of a filter rule (execute or executec), or to perform the filtering itself.

Users requiring assistance can either call the ITS Customer Support Center at 213-740-5555, or send an email to consult@usc.edu.