{"id":4845,"date":"2018-07-02T10:59:53","date_gmt":"2018-07-02T14:59:53","guid":{"rendered":"https:\/\/www.pair.com\/support\/kb\/?post_type=ht_kb&#038;p=4845"},"modified":"2026-07-01T09:37:34","modified_gmt":"2026-07-01T13:37:34","slug":"sieve-syntax-and-common-recipes","status":"publish","type":"ht_kb","link":"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/","title":{"rendered":"Sieve Syntax and Common Recipes"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">Learn about sieve syntax and how recipes are set up. This article is not a comprehensive list of everything that sieve can do, but rather a guide to helping you get started with sieve. If you want more information about what sieve is, see our article <\/span><span style=\"font-weight: 400;\"><a href=\"https:\/\/www.pair.com\/support\/kb\/what-is-sieve-email-filtering\/\">What is Sieve Filtering<\/a>?<\/span><\/p>\n<h3>Syntax<\/h3>\n<p><span style=\"font-weight: 400;\">Below is the basic format of a sieve script. Depending on your chosen email client you may need to know the syntax in order to write your own sieve rules. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Sieve uses <\/span><i><span style=\"font-weight: 400;\">if<\/span><\/i><span style=\"font-weight: 400;\"> statements to test the email. If the condition following the <\/span><em><span style=\"font-weight: 400;\">if<\/span><\/em><span style=\"font-weight: 400;\"> is not met, then the email will move on to the next statement or, if there are no more statements, go to the inbox. <\/span><\/p>\n<pre><span style=\"font-weight: 400;\">if &lt;condition&gt; {<\/span>\n<span style=\"font-weight: 400;\">&lt;action&gt;; <\/span>\n<span style=\"font-weight: 400;\">&lt;action&gt;; <\/span>\n<span style=\"font-weight: 400;\">...<\/span>\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Sieve also uses <\/span><i><span style=\"font-weight: 400;\">else if<\/span><\/i><span style=\"font-weight: 400;\"> statements so that you can test multiple conditions in a succession if the first statement is not met. <\/span><\/p>\n<pre><span style=\"font-weight: 400;\">if &lt;condition&gt; {<\/span>\n<span style=\"font-weight: 400;\">&lt;action&gt;; <\/span>\n<span style=\"font-weight: 400;\">&lt;action&gt;; <\/span>\n<span style=\"font-weight: 400;\">...<\/span>\n<span style=\"font-weight: 400;\">}<\/span>\n\n<span style=\"font-weight: 400;\">else if &lt;condition&gt; {<\/span>\n<span style=\"font-weight: 400;\">&lt;action&gt;;<\/span>\n<span style=\"font-weight: 400;\">...<\/span>\n<span style=\"font-weight: 400;\">}<\/span>\n\n<span style=\"font-weight: 400;\">else {<\/span>\n<span style=\"font-weight: 400;\">&lt;action&gt;;<\/span>\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">The <\/span><span style=\"font-weight: 400;\">&lt;condition&gt;<\/span><span style=\"font-weight: 400;\"> specifies the part of the email that should be tested and what it should be tested for.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The &lt;action&gt; indicates what to do with the email if it meets the requirements. For example, you might redirect the email.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For more information about the different types of actions, conditions, and more sieve syntax, <\/span><a href=\"http:\/\/thsmi.github.io\/sieve-reference\/en\/index.html\"><span style=\"font-weight: 400;\">check out this great resource by Thomas Schmid<\/span><\/a><span style=\"font-weight: 400;\">. <\/span><\/p>\n<h3>Common Recipes<\/h3>\n<p><span style=\"font-weight: 400;\">If you want to use sieve to help filter your email, you can use these basic recipes to help you get started.<\/span><\/p>\n<h4>Automatically Delete Mail from a Specific Address<\/h4>\n<p><span style=\"font-weight: 400;\">If you want to automatically delete mail from an address, you can do so. Here is an example of what the command may look like:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">if address :is \u201cFrom\u201d \u201cbad@example.com\u201d {<\/span>\n<span style=\"font-weight: 400;\">discard;<\/span>\n<span style=\"font-weight: 400;\">stop;<\/span>\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">By using <\/span><span style=\"font-weight: 400;\">address <\/span><span style=\"font-weight: 400;\">and<\/span><span style=\"font-weight: 400;\"> \u201cFrom\u201d<\/span><span style=\"font-weight: 400;\">, the command will search incoming email\u2019s <\/span><i><span style=\"font-weight: 400;\">From<\/span><\/i><span style=\"font-weight: 400;\"> address to see if it matches the contents of the second quotations. In this case, the contents is <\/span><i><span style=\"font-weight: 400;\">bad@example.com<\/span><\/i><span style=\"font-weight: 400;\">. If the <\/span><i><span style=\"font-weight: 400;\">From<\/span><\/i><span style=\"font-weight: 400;\"> address matches <\/span><i><span style=\"font-weight: 400;\">bad@example.com<\/span><\/i><span style=\"font-weight: 400;\">, then the <\/span><span style=\"font-weight: 400;\">discard <\/span><span style=\"font-weight: 400;\">action will run. The <\/span><span style=\"font-weight: 400;\">discard<\/span><span style=\"font-weight: 400;\"> action immediately deletes the email, keeping it from landing in your inbox.<\/span><\/p>\n<h4>Redirecting Mail Based on Subject Line<\/h4>\n<p><span style=\"font-weight: 400;\">If you want to redirect mail based on words in the subject line, the command will look like the following:<\/span><\/p>\n<pre><span style=\"font-weight: 400; color: #000000;\">if header :contains \u201csubject\u201d \u201chelp\u201d {<\/span>\n\n<span style=\"color: #000000;\"><span style=\"font-weight: 400;\">redirect \u201c<\/span><a style=\"color: #000000;\" href=\"mailto:support@example.com\"><span style=\"font-weight: 400;\">support@example.com<\/span><\/a><span style=\"font-weight: 400;\">\u201d;<\/span><\/span>\n\n<span style=\"font-weight: 400; color: #000000;\">stop;<\/span>\n\n<span style=\"font-weight: 400; color: #000000;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">By using <\/span><span style=\"font-weight: 400; font-family: monospace;\">header<\/span><span style=\"font-weight: 400;\"> in the conditional statement, the command checks the entire email header. By using \u201csubject,\u201d we narrow down the results to only the subject line. After that, we establish the word we are looking for in the subject line: \u201chelp.\u201d <\/span><\/p>\n<p><span style=\"font-weight: 400;\">If the conditions of the rule are met, then the action will be executed. In this case, if the subject line contains the word \u201chelp\u201d, then the email will be redirected to <\/span><i><span style=\"font-weight: 400;\">support@example.com<\/span><\/i><span style=\"font-weight: 400;\">. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you want to search for multiple words in the subject line, you can do so by adding brackets around the words that could be found in the subject line.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">if header :contains \u201csubject\u201d [ \u201chelp\u201d, \u201cassistance\u201d, \u201cproblem\u201d] {<\/span>\n<span style=\"font-weight: 400;\">redirect \u201c<\/span><a href=\"mailto:support@example.com\"><span style=\"font-weight: 400;\">support@example.com<\/span><\/a><span style=\"font-weight: 400;\">\u201d;<\/span>\n<span style=\"font-weight: 400;\">stop;<\/span>\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">If any of the words listed within the brackets are found in the subject line, the email will be redirected. Only one word needs to be found in order for the command to execute.<\/span><\/p>\n<h4>Combining More than One Condition<\/h4>\n<p><span style=\"font-weight: 400;\">If you want to filter an email based on multiple conditions, you can. By using all of, you can list multiple conditions that the email must meet before the action is run. <\/span><\/p>\n<pre><span style=\"font-weight: 400;\">if allof ( address :is \u201cFrom\u201d \u201ccustomer@example.com\u201d, header :contains \u201csubject\u201d \u201corder\u201d ) {<\/span>\n<span style=\"font-weight: 400;\">fileinto \u201cSales Folder\u201d;<\/span>\n<span style=\"font-weight: 400;\">stop;<\/span>\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">The example command above will check incoming mail to see if it is from the address <\/span><i><span style=\"font-weight: 400;\">customer@example.com<\/span><\/i><span style=\"font-weight: 400;\">. If it is, it will also see if it contains the word \u201corder\u201d in the subject line. If both these conditions are met, the email will be sent to the \u201cSales Folder.\u201d <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn about sieve syntax and how recipes are set up. This article is not a comprehensive list of everything that sieve can do, but rather a guide to helping you get started with sieve. If you want more information about what sieve is, see our article What is Sieve Filtering?&#8230;<\/p>\n","protected":false},"author":11,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":[],"ht-kb-category":[20],"ht-kb-tag":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Sieve Syntax and Common Recipes - Knowledge Base - Pair Networks<\/title>\n<meta name=\"description\" content=\"Learn about sieve and how recipes are set up. This article is not a comprehensive list of everything sieve can do, but guide to helping you get started.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sieve Syntax and Common Recipes - Knowledge Base - Pair Networks\" \/>\n<meta property=\"og:description\" content=\"Learn about sieve and how recipes are set up. This article is not a comprehensive list of everything sieve can do, but guide to helping you get started.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/\" \/>\n<meta property=\"og:site_name\" content=\"Knowledge Base - Pair Networks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pairnetworks\/\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-01T13:37:34+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@pairNetworks\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/\",\"url\":\"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/\",\"name\":\"Sieve Syntax and Common Recipes - Knowledge Base - Pair Networks\",\"isPartOf\":{\"@id\":\"https:\/\/www.pair.com\/support\/kb\/#website\"},\"datePublished\":\"2018-07-02T14:59:53+00:00\",\"dateModified\":\"2026-07-01T13:37:34+00:00\",\"description\":\"Learn about sieve and how recipes are set up. This article is not a comprehensive list of everything sieve can do, but guide to helping you get started.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pair.com\/support\/kb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sieve Syntax and Common Recipes\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pair.com\/support\/kb\/#website\",\"url\":\"https:\/\/www.pair.com\/support\/kb\/\",\"name\":\"Knowledge Base - Pair Networks\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.pair.com\/support\/kb\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pair.com\/support\/kb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pair.com\/support\/kb\/#organization\",\"name\":\"Pair Networks\",\"url\":\"https:\/\/www.pair.com\/support\/kb\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pair.com\/support\/kb\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.pair.com\/support\/kb\/wp-content\/uploads\/2022\/02\/Gb_TUkUE_400x400.jpeg\",\"contentUrl\":\"https:\/\/www.pair.com\/support\/kb\/wp-content\/uploads\/2022\/02\/Gb_TUkUE_400x400.jpeg\",\"width\":360,\"height\":360,\"caption\":\"Pair Networks\"},\"image\":{\"@id\":\"https:\/\/www.pair.com\/support\/kb\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/pairnetworks\/\",\"https:\/\/twitter.com\/pairNetworks\",\"https:\/\/www.instagram.com\/pairnetworks\/\",\"https:\/\/www.linkedin.com\/company\/2269676\/\",\"https:\/\/www.pinterest.com\/pairnetworksinc\/pins\/\",\"https:\/\/www.youtube.com\/user\/pairnetworks\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sieve Syntax and Common Recipes - Knowledge Base - Pair Networks","description":"Learn about sieve and how recipes are set up. This article is not a comprehensive list of everything sieve can do, but guide to helping you get started.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/","og_locale":"en_US","og_type":"article","og_title":"Sieve Syntax and Common Recipes - Knowledge Base - Pair Networks","og_description":"Learn about sieve and how recipes are set up. This article is not a comprehensive list of everything sieve can do, but guide to helping you get started.","og_url":"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/","og_site_name":"Knowledge Base - Pair Networks","article_publisher":"https:\/\/www.facebook.com\/pairnetworks\/","article_modified_time":"2026-07-01T13:37:34+00:00","twitter_card":"summary_large_image","twitter_site":"@pairNetworks","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/","url":"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/","name":"Sieve Syntax and Common Recipes - Knowledge Base - Pair Networks","isPartOf":{"@id":"https:\/\/www.pair.com\/support\/kb\/#website"},"datePublished":"2018-07-02T14:59:53+00:00","dateModified":"2026-07-01T13:37:34+00:00","description":"Learn about sieve and how recipes are set up. This article is not a comprehensive list of everything sieve can do, but guide to helping you get started.","breadcrumb":{"@id":"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pair.com\/support\/kb\/sieve-syntax-and-common-recipes\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pair.com\/support\/kb\/"},{"@type":"ListItem","position":2,"name":"Sieve Syntax and Common Recipes"}]},{"@type":"WebSite","@id":"https:\/\/www.pair.com\/support\/kb\/#website","url":"https:\/\/www.pair.com\/support\/kb\/","name":"Knowledge Base - Pair Networks","description":"","publisher":{"@id":"https:\/\/www.pair.com\/support\/kb\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pair.com\/support\/kb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pair.com\/support\/kb\/#organization","name":"Pair Networks","url":"https:\/\/www.pair.com\/support\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pair.com\/support\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.pair.com\/support\/kb\/wp-content\/uploads\/2022\/02\/Gb_TUkUE_400x400.jpeg","contentUrl":"https:\/\/www.pair.com\/support\/kb\/wp-content\/uploads\/2022\/02\/Gb_TUkUE_400x400.jpeg","width":360,"height":360,"caption":"Pair Networks"},"image":{"@id":"https:\/\/www.pair.com\/support\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/pairnetworks\/","https:\/\/twitter.com\/pairNetworks","https:\/\/www.instagram.com\/pairnetworks\/","https:\/\/www.linkedin.com\/company\/2269676\/","https:\/\/www.pinterest.com\/pairnetworksinc\/pins\/","https:\/\/www.youtube.com\/user\/pairnetworks"]}]}},"_links":{"self":[{"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/ht-kb\/4845"}],"collection":[{"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/comments?post=4845"}],"version-history":[{"count":5,"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/ht-kb\/4845\/revisions"}],"predecessor-version":[{"id":10673,"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/ht-kb\/4845\/revisions\/10673"}],"wp:attachment":[{"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/media?parent=4845"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/ht-kb-category?post=4845"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.pair.com\/support\/kb\/wp-json\/wp\/v2\/ht-kb-tag?post=4845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}