Carnegie Mellon University Website Home Page
 

Developing Sieve Scripts

Included in this section are some examples of Sieve scripts. Multiple Sieve scripts can be used together so that only e-mail that passes each of the Sieve script criteria would appear in your INBOX. See example E.

Important Note: Sieve scripting is a programming language whose use is reserved for those familiar with programming code. Those who attempt to develop and use a Sieve script, should be familiar with basic scripting language and with Sieve specifically.

Example A: This Sieve script will reject a nuisance e-mail message that consistently includes "Circle" in the subject field. In this example, before implementing the script, a "Circle List" folder would be created. All e-mail that meets the criteria will be deposited into the "Circle List" folder.

Note: In this example, the following must appear as the first line of the script: require ["fileinto"];

if header :contains "Subject" "[CIRCLE]" {fileinto "INBOX.Circle List";}

Example B: This Sieve script will reject a specific mail virus that consistently includes "A great Shockwave flash movie" in the subject field.

if header :contains "Subject" "A great Shockwave flash movie" {reject "Possible virus? Check your system!";}

Example C: This Sieve script will copy all e-mail sent from dial-up uu.net account into a junk folder. The script is effective even if mail is relayed through an international open mail relay. Before you enable the script, create a junk mail folder under your INBOX.

Note: In this example, the following must appear as the first line of the script: require ["fileinto"];

if header :contains "Received" ".da.uu.net" {fileinto "INBOX.Junk";}

Example D: This Sieve script will reject junk e-mail where the "To" field includes "bigfoot.com". Typically, mail address to "bigfoot" is spam.

if header :contains "To" "@bigfoot.com" {reject "Please remove my name from your mailing list";}

Example E: This Sieve script will reject e-mail where the "To" field does not include your name or e-mail address. Typically, this type of mail is spam. Before you enable the script, create a junk mail folder under your INBOX.

Note: In this example, the following must appear as the first line of the script: require ["fileinto"];

if anyof ( not address :all :contains ["To", "Cc", "Bcc"] "yourname@youraddress.com" ) {fileinto "INBOX.Junk";}

Note: Other useful Sieveshell commands are "get", "list", "delete", and "deactivate". Only one Sieve script may be active at any given time.

Last Updated: 6/20/07