Using Electronic Mail on the local system

Controlling mail with mailrule

Author: L.S.Lowe. File: mailrule. This update: 20120114. Part of Guide to the Local System.

Introduction

This document has been updated to reflect the change at the computer centre from the opt-in CUBE system to the STAMP system. Also, mailrule is not totally about spam, it also has other useful functions: read the later Other Features section.

If you have read this document about STAMP, you will already know that the campus STAMP system filters or flags email identified as spam, for all users. You may then feel that the level of spam you are getting is small enough that you want to take no further action. This is fine.

If you feel you are getting too much spam, then the choices are:

  • You can still receive all email into your normal inbox. This is the most basic option, and not really recommended.
  • As above, but with a flexible mail client, like pine, you can mark identified-spam in a different colour. Not much better!
  • You can request the system to put email identified as spam into a separate folder called spam in the same directory as your inbox.
This document is about the last choice, which is what is recommended if you get a significant amount of spam.

How to enable a separate incoming spam folder using mailrule

To enable the separation of spam into a separate folder, enter the following commands:
          mailrule enable
          mailrule filterspam

This sets up your control files for our email delivery system procmail so that mail that has been flagged as spam under our three criteria get stored in your spam folder; the criteria are:

  • Mail flagged by the campus STAMP system as spam, at a threshold our group determines;
  • Mail flagged by the CERN mailer as spam (and maybe other such sites in the future);
  • Mail identified locally as spam by our own rules, administered by LSL.

The advantage of using this locally-provided way of setting up your procmail control files, is that when I update these files that I supply, yours will automatically be updated too (as they are hard-linked files).

As well as these system-provided files, an additional control file is created for your customisations via mailrule. See next section.

Adding Approved Contacts using mailrule

Adding Approved Contacts is not necessary in many circumstances. But you may find by experience that some users can be susceptible to having their email regarded as spam by the campus STAMP system.

For such users, enter:

          mailrule add user@host
and a rule will be added to your .procuser file which requests email from that person to be stored always in your inbox folder, and not the spam folder.

If you want to clear all existing user rules and start again, enter mailrule clearalluser.

How to request that spams are cleaned-out regularly

Unless you clean-up or rename your spam folder occasionally yourself, it will grow forever, just like other folders. But you can opt-in to have your spam folder cleaned regularly, by entering once:
          mailrule autoclean
After that, old emails will be removed from the spam folder at regular intervals. This is a bit like on well-known mail-service providers like Hotmail and Yahoo, but less frequent. For us, old emails are ones received over a month ago: for example, during July, emails received before June and July are old. The spam folder contents will be retained from the first non-old email.

If you opt-in to the autoclean, you can still delete mails in the spam folder yourself if you really want to. And you can opt-out again by using

          mailrule noautoclean

How to check your spam folder as a separate pine process

To check that the mail in your spam folder is indeed spam, and not that important email that you've been waiting for, you should check your spam folder occasionally.

To do this as a separate pine process, you can simply enter

          pines 

This starts up pine to look at the spam folder. You can leave it going in that window, or quit until next time. It is equivalent to pine -i -f /home/mail/user/spam.

How to tune pine to look in both inbox and spam folders

An alternative is to tune your pine setup so that it is able to look in both incoming mail folders: inbox and spam. This gives a different look to the way pine handles folders: I use it myself, but you may prefer not to change the way things look.

If you want to set it up, do the following:

  • In pine Setup, under Folder Preferences, set enable-incoming-folders.
  • After that, when you choose the Folder List option on the Main menu, you get an extra choice of Incoming Folders or Mail local folders. The second of these corresponds to the folders in your $HOME/Mail directory that you are already familiar with.
  • Choose Incoming Folders. You should simply see INBOX at this stage.
  • Select A for Add to add the spam folder as an incoming folder. Give a null server name, give the folder name of /home/mail/userid/spam, and a nickname of (say) Incoming spam.
  • After that, you can use the TAB key at the end of a folder index to switch to a different incoming folder, that is, between inbox and spam. Or you can go into a Folder List on the Main menu and choose it from there.

Even more incoming folders

As an extension to mailrule, for more advanced use, you can designate a target folder other than inbox on the mailrule command. Instead of user@host, specify user@host:folder, where the folder will reside in directory /home/mail/user/, like the inbox. As with spam, you will need to have a method to view this folder. If using pine, you may well want to enable-incoming-folders, as described in the previous section.

Be aware that all incoming folders for mail delivery purposes are in the mail directory /home/mail/user/, and not in $HOME/Mail. This is not a problem: it's just another place for email to be stored.

Experienced users

Experienced users who want to do their own thing should first read man procmail and its associated man files and tips doc. But if you lose email doing your own thing, don't blame me!

How to report email or spam that has been misidentified

If you are using the mailrule facility, and spam finds itself into your normal inbox, then report it to me by bouncing the email to reportspam.

If you are using the mailrule facility, and legitimate email finds itself into your spam folder, then report it to me by bouncing the email to reportgood.

In pine, use the B command to do a bounce. I check the emails that have been reported in this way every few days, and if I can see a way of refining the rules to avoid misidentification in future, I take action. However, if such misidentification is likely to occur regularly for a particular sender, such as a hotmail sender, it's up to you to help yourself by adding such a user as an Approved Contact using the mailrule command (see above).

Other features of mailrule

  • mailrule help: use this command to summarise the subcommands of mailrule.
  • mailrule status: use this command to summarise your current mailrule setup, if any.
  • mailrule enable: use this command to set-up an initial procmail file needed by mailrule.
  • mailrule respond: use this command to enable an automatic responder for incoming mail. All suitable incoming email will be responded to with a vacation message; only the first such email from each correspondent will be responded to. Mail from mailing lists, or suspected spam emails, will not be responded to.
  • mailrule editrespond: This allows you to personalise your vacation message.
  • mailrule norespond: this turns off the local respond facility, for when you return.

  • mailrule forward remoteaccount: you can use this to set up forwarding from your local account to a remote account. If you instead use +remoteaccount, a copy of emails is kept locally too.
  • mailrule noforward: forwarding is turned off. You can later turn it back on with mailrule forward with no extra operand.
  • mailrule editforward: you can use this to create or edit or delete a mail forwarding control file. The command invokes an editor: in the editor, the format for lines is to put one userid@host on each line. Precede the userid with a backslash if it's your own local id. If you delete all lines in the file, then the file itself is also deleted.

    These forward commands are a bit anomalous in that they use the standard forward mechanism of sendmail, which applies before the email reaches procmail and any procmail rules that mailrule may have set up. So if mail is forwarded in this way solely to another location, then none of the other features of mailrule come into play while that forwarding is in effect. A future version of mailrule may add more flexibility in this respect. If on the other hand you are keeping a copy in your local mailbox (by using the + notation above, say), then other aspects of mailrule will work, like respond.

Other features may have been added to mailrule but not yet documented, and more features can be added: chat to Lawrie Lowe.

L.S.Lowe