UCSD Main WebsiteUCSD Jacobs SchoolDepartment of Computer Science and Engineering
About CSECSE PeopleFacultyGraduate EducationUndergraduate EducationDepartment AdministrationContact CSE
spacer gif
spacer gif
CSE People
spacer gifspacer gif
spacer gif
plus signspacer gifAcademic Affairs
spacer gif
spacer gifspacer gifFaculty/Staff Intranet
spacer gif
plus signspacer gifFinancial Affairs
spacer gif
plus signspacer gifHuman Resources
spacer gif
minus signspacer gifComputing Support
spacer gifspacer gifServices
spacer gifspacer gifResources for TAs & Instructors
spacer gifspacer gifFacilities
spacer gifspacer gifRequest Help
spacer gifspacer gifOther Resources
spacer gifspacer gifWindows Resources
spacer gifspacer gifComputing Policy
spacer gif
plus signspacer gifFacilities
spacer gif
spacer gifspacer gifComputing FAQ
spacer gif
spacer gif
spacer gif
Search
spacer gifspacer gifspacer gif
 
 
Google
spacer gifspacer gif
spacer gif
spacer gif
spacer gif
spacer gif
spacer gifspacer gif
Home»Department Administration»Computing Support»Other resources»Email»Spam»Filing Spam with procmail
spacer gif
Filing Spam with Procmail
spacer gif
spacer gifspacer gifspacer gif
spacer gif

What is "procmail"?
Procmail is a mail filtering tool for Unix systems that uses a well-formed rules file to determine what messages, if any, should be sent to what mailboxes. If you would like server-side mail filtering and are not already comfortable with using procmail, please feel free to contact CSEHelp for assistance in setting up procmail filtering for spam.

To filter with procmail, you'll need to log on to your mail server with SSH and edit the file ".procmailrc" in your home directory. Exactly what you use for the rule will depend on how you file your email messages, but it would look something like this:

	:0
	* ^X-Barracuda-Spam-Status: Yes.*
	mail/Spam-Barracuda
    

Looking at this in detail, the first line tells procmail that this is a new rule. The second line tells procmail to look for a line that starts with "X-Barracuda-Spam-Status: Yes" and might or might not have any text after that. If a mail message has that line in it, then the third line tells procmail what to do with it. In this case, we're filing it in a mailbox called "Spam-Barracuda".

The location of the mailbox file is important, and for historical reasons, it varies between users. Your mail folders will typically be in one of the following locations in your home directory (${HOME}):

  • ${HOME}/mail
  • ${HOME}/Imail
  • ${HOME}/Mail
Other variations, however, have been found while helping people with mail issues in the past. If you are unsure of exactly where your mail folders are, please contact CSEHelp for assistance, and we will happily work with you to set up an appropriate rule.

Any message which scores a 5.0 or higher in the Barracuda's spam scoring system will be tagged as spam and receive a "Yes" in the "X-Barracuda-Spam-Status" header, and the above rule will file all such messages away from your Inbox for you. Be sure to check this folder for legitimate messages, as occasionally the Barracuda can mark a non-spam message as spam due to some characteristic of the message.

If you find that not enough spam messages are being caught by the Barracuda's spam scoring, and would like to use a slightly more aggressive filter, you can add another rule to your .procmailrc file to filter messages with Barracuda scores lower than 5. For example, you might decide that you don't really want to see anything that scores a 4.0 or higher, and add something that might look like this after the above rule:

	:0
	* ^X-Barracuda-Spam-Score: [4-9].*
	mail/Spam-Maybe
    

This will take any message that didn't get caught by the first rule above, and, if it has a spam score of 4 or higher, file it in a mailbox called "Spam-Maybe". The same caveats for the first rule apply here as well, and you will likely need to adjust the mailbox path to suite your personal configuration.

Be careful about lowering the spam score, however, as being too agressive with the spam score can lead to legitimate email messages being filed away in your spam mailbox. It is your own responsibility to check your spam folders for messages which should not have been filed as spam.

Procmail Examples
Here are some example procmail recipies you can use. Be sure to replace "YOUR_MAIL_DIRECTORY_HERE" with the path to your mail folder directory.


Store all mail with a score of 5 or higher in a folder named "Spam":
	:0
	* ^X-Barracuda-Spam-Status: Yes.*
	YOUR_MAIL_DIRECTORY_HERE/Spam
    


Store all mail with a score of 5 or higher in a folder named "Spam-Barracuda" and store mail with a score between 4 and 5 in a folder called "Spam-Maybe":
	:0
	* ^X-Barracuda-Spam-Status: Yes.*
	YOUR_MAIL_DIRECTORY_HERE/Spam-Barracuda

	:0
	* ^X-Barracuda-Spam-Score: [4-9].*
	YOUR_MAIL_DIRECTORY_HERE/Spam-Maybe
    


Store all mail with a score of 4 or higher in a folder named "Spam". The "4" in the rule below can be changed to any number between 1 and 9 to tighten or lossen the filtering. The second part of the regular expression catches scores of 10 or higher:
	:0
	* ^X-Barracuda-Spam-Score: ([4-9]|[1-9][0-9]).*
	YOUR_MAIL_DIRECTORY_HERE/Spam
    


Store all mail with a score of 3.5 or higher in a folder named "Spam". If you want to pick a different value, it is important to change both the 3 and the 4 to appropriate sequential values (such as 2 and 3). The 5 can be changed to the desired tenth of a score:
	:0
	* ^X-Barracuda-Spam-Score: (3\.[5-9]|[4-9]|[1-9][0-9]).*
	YOUR_MAIL_DIRECTORY_HERE/Spam
    


spacer gif
spacer gif
spacer gifback to top ^
spacer gif
spacer gif
spacer gif
spacer gif
9500 Gilman Drive, La Jolla, CA 92093-0404
spacer gif
About CSE | CSE People | Faculty & Research | Graduate Education | Undergraduate Education
Department Administration | Contact CSE | Help | Search | Site map | Home
webmaster@cs.ucsd.edu
Official web page of the University of California, San Diego
Copyright © 2003 Regents of the University of California. All rights reserved.
spacer gif