 |
 |
 |
Information Technology Services
ITS System Information
How can I create a filter to get rid of unwanted mail?
The filter program allows
you to define a set of rules by which all incoming mail is
screened, and a subsequent set of actions to perform based
on whether the conditions are met or not. Filter also has
the ability to mail a summary of what actions it performed
on the incoming mail as often as you'd like.
- To setup a mail filter, you need to first connect to the server (either
mail.rochester.edu or troi.cc.rochester.edu using SSH (secure
shell) or Telnet. For instructions, please see
Connecting using SSH.
- Once you have connected to the server, you will need to create a .forward
file (a file named .forward) using the "Joe" text editor. You can
do so by typing the following command at the mail%
or troi% prompt:
joe .forward
- In the .forward file, put the following line (with the quotations and all
on one line):
"|/usr/ucc/bin/filter -vo /var/tmp/filter.userid"
Replace "userid" with your login name.
This file tells the system that all mail received is to go to through the
filter program before it goes to your inbox.
- Then, save this file. In Joe this is done by typing Control-K (type the letter K while holding down the control key) then typing the letter X.
- Next, you need to create a filter-rules file (a file named
filter-rules) in the .elm subdirectory of your home
directory. You must first create the .elm directory by typing:
mkdir .elm
- Now you can edit the filter-rules file by typing:
joe .elm/filter-rules
- In this file you can put commands in the following form:
if (to = "mail@entrepreneur.com") then delete
if (subject contains "key-word") then save
- "~/Mail/folder"
always forward "cymi@mail.rochester.edu"
- The first rule tells the filter program to delete any mail
from mail@entrepreneur.com.
- The second rule tells the filter program if you see key-word the save that
message to a folder.
- The third message will always be executed. This rule says always forward
the message to cymi@mail.rochester.edu.
- NOTE: If your command takes up more than one line, be sure to indent
any lines after the first one so that it will be interpreted as part of the
same command.
You can filter based on the fields from, to, and subject.
The actions you can take are:
- save folder-name -- Save into the folder "folder-name"
- delete -- Delete the message completely
- savecopy folder-name -- Leave a copy in the inbox and also save a copy to the folder "folder-name"
- execute command -- Execute a UNIX shell command
- forward user@address -- Forward message to "user@address"
- forwardc user@address -- Leave a copy in the inbox and also
forward a copy to "user@address"
- leave -- Leave message in inbox; take no action
When you are finished editing your filter-rules, save the file by typing
Control-K then X.
- To test your filter, you can type in the command
filter -r
and you should get the following output for the above rules:
Rule 1: if (to = "mail@entrepreneur.com") then
Delete
Rule 2: if (subject = "key-word") then
Save ~/Mail/folder
Rule 3: ** always **
Forward cymi@mail.rochester.edu
If you get an error message, there may be a typo in your filter-rules file. Repeat steps 6 and 7 and doublecheck your rules, or write
to problem@mail.rochester.edu or problem@troi.cc.rochester.edu and include the
error message.
For more detailed information on the filter command you can
type:
man filter
at the mail% or troi% prompt to see the on-line manual entry.
Last updated April 8, 2002
If you couldn't find the help you needed, or if you have suggestions or
corrections to this document, please let us know by sending electronic mail,
appropriately, to:
problem@mail.rochester.edu or
problem@troi.cc.rochester.edu
Please note that we only provide support for our systems. If you send
us a problem from outside mail or troi we cannot answer it.
|
 |