{
    "mode": "man",
    "parameter": "body_checks",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/body_checks/5/json",
    "generated": "2026-06-16T09:50:41Z",
    "synopsis": "headerchecks = pcre:/etc/postfix/headerchecks\nmimeheaderchecks = pcre:/etc/postfix/mimeheaderchecks\nnestedheaderchecks = pcre:/etc/postfix/nestedheaderchecks\nbodychecks = pcre:/etc/postfix/bodychecks\nmilterheaderchecks = pcre:/etc/postfix/milterheaderchecks\nsmtpheaderchecks = pcre:/etc/postfix/smtpheaderchecks\nsmtpmimeheaderchecks = pcre:/etc/postfix/smtpmimeheaderchecks\nsmtpnestedheaderchecks = pcre:/etc/postfix/smtpnestedheaderchecks\nsmtpbodychecks = pcre:/etc/postfix/smtpbodychecks\npostmap -q \"string\" pcre:/etc/postfix/filename\npostmap -q - pcre:/etc/postfix/filename <inputfile",
    "sections": {
        "NAME": {
            "content": "headerchecks - Postfix built-in content inspection\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "headerchecks = pcre:/etc/postfix/headerchecks\nmimeheaderchecks = pcre:/etc/postfix/mimeheaderchecks\nnestedheaderchecks = pcre:/etc/postfix/nestedheaderchecks\nbodychecks = pcre:/etc/postfix/bodychecks\n\nmilterheaderchecks = pcre:/etc/postfix/milterheaderchecks\n\nsmtpheaderchecks = pcre:/etc/postfix/smtpheaderchecks\nsmtpmimeheaderchecks = pcre:/etc/postfix/smtpmimeheaderchecks\nsmtpnestedheaderchecks = pcre:/etc/postfix/smtpnestedheaderchecks\nsmtpbodychecks = pcre:/etc/postfix/smtpbodychecks\n\npostmap -q \"string\" pcre:/etc/postfix/filename\npostmap -q - pcre:/etc/postfix/filename <inputfile\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This  document  describes  access  control on the content of message headers and message body\nlines; it is implemented by the Postfix cleanup(8) server before mail  is  queued.   See  ac‐‐\ncess(5) for access control on remote SMTP client information.\n\nEach  message  header  or  message  body line is compared against a list of patterns.  When a\nmatch is found the corresponding action is executed, and the matching process is repeated for\nthe next message header or message body line.\n\nNote:  message  headers are examined one logical header at a time, even when a message header\nspans multiple lines. Body lines are always examined one line at a time.\n\nFor examples, see the EXAMPLES section at the end of this manual page.\n\nPostfix header or bodychecks are designed to stop a flood of mail  from  worms  or  viruses;\nthey  do not decode attachments, and they do not unzip archives. See the documents referenced\nbelow in the README FILES section if you need more sophisticated content analysis.\n",
            "subsections": []
        },
        "FILTERS WHILE RECEIVING MAIL": {
            "content": "Postfix implements the following four built-in content  inspection  classes  while  receiving\nmail:\n\nheaderchecks (default: empty)\nThese  are  applied  to  initial message headers (except for the headers that are pro‐\ncessed with mimeheaderchecks).\n\nmimeheaderchecks (default: $headerchecks)\nThese are applied to MIME related message headers only.\n\nThis feature is available in Postfix 2.0 and later.\n\nnestedheaderchecks (default: $headerchecks)\nThese are applied to message headers of attached email messages (except for the  head‐\ners that are processed with mimeheaderchecks).\n\nThis feature is available in Postfix 2.0 and later.\n\nbodychecks\nThese are applied to all other content, including multi-part message boundaries.\n\nWith  Postfix  versions  before  2.0, all content after the initial message headers is\ntreated as body content.\n",
            "subsections": []
        },
        "FILTERS AFTER RECEIVING MAIL": {
            "content": "Postfix supports a subset of the built-in content inspection classes after the message is re‐\nceived:\n\nmilterheaderchecks (default: empty)\nThese are applied to headers that are added with Milter applications.\n\nThis feature is available in Postfix 2.7 and later.\n",
            "subsections": []
        },
        "FILTERS WHILE DELIVERING MAIL": {
            "content": "Postfix supports all four content inspection classes while delivering mail via SMTP.\n\nsmtpheaderchecks (default: empty)\n\nsmtpmimeheaderchecks (default: empty)\n\nsmtpnestedheaderchecks (default: empty)\n\nsmtpbodychecks (default: empty)\nThese features are available in Postfix 2.5 and later.\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "With  Postfix  version  2.2  and earlier specify \"postmap -fq\" to query a table that contains\ncase sensitive patterns. By default, regexp: and pcre: patterns are case insensitive.\n",
            "subsections": []
        },
        "TABLE FORMAT": {
            "content": "This document assumes that header and bodychecks rules are specified in the form of  Postfix\nregular  expression  lookup  tables. Usually the best performance is obtained with pcre (Perl\nCompatible Regular Expression) tables. The regexp (POSIX regular expressions) tables are usu‐\nally  slower,  but  more  widely  available.   Use the command \"postconf -m\" to find out what\nlookup table types your Postfix system supports.\n\nThe general format of Postfix regular expression tables is given below.  For a discussion  of\nspecific pattern or flags syntax, see pcretable(5) or regexptable(5), respectively.\n\n/pattern/flags action\nWhen  /pattern/  matches the input string, execute the corresponding action. See below\nfor a list of possible actions.\n\n!/pattern/flags action\nWhen /pattern/ does not match the input string, execute the corresponding action.\n\nif /pattern/flags\n\nendif  If the input string matches /pattern/, then match that input string against  the  pat‐\nterns between if and endif.  The if..endif can nest.\n\nNote: do not prepend whitespace to patterns inside if..endif.\n\nif !/pattern/flags\n\nendif  If the input string does not match /pattern/, then match that input string against the\npatterns between if and endif. The if..endif can nest.\n\nblank lines and comments\nEmpty lines and whitespace-only lines are ignored, as are lines whose first non-white‐\nspace character is a `#'.\n\nmulti-line text\nA  pattern/action line starts with non-whitespace text. A line that starts with white‐\nspace continues a logical line.\n",
            "subsections": []
        },
        "TABLE SEARCH ORDER": {
            "content": "For each line of message input, the patterns are applied in the order as specified in the ta‐\nble.  When  a  pattern is found that matches the input line, the corresponding action is exe‐\ncuted and then the next input line is inspected.\n",
            "subsections": []
        },
        "TEXT SUBSTITUTION": {
            "content": "Substitution of substrings from the matched expression into the action string is possible us‐\ning the conventional Perl syntax ($1, $2, etc.).  The macros in the result string may need to\nbe written as ${n} or $(n) if they aren't followed by whitespace.\n\nNote: since negated patterns (those preceded by !) return a result when the  expression  does\nnot match, substitutions are not available for negated patterns.\n",
            "subsections": []
        },
        "ACTIONS": {
            "content": "Action  names  are  case insensitive. They are shown in upper case for consistency with other\nPostfix documentation.\n\nBCC user@domain\nAdd the specified address as a BCC recipient, and inspect the next input line. The ad‐\ndress  must have a local part and domain part. The number of BCC addresses that can be\nadded is limited only by the amount of available storage space.\n\nNote 1: the BCC address is added as if it was specified with NOTIFY=NONE.  The  sender\nwill not be notified when the BCC address is undeliverable, as long as all down-stream\nsoftware implements RFC 3461.\n\nNote 2: this ignores duplicate addresses (with the same delivery  status  notification\noptions).\n\nThis feature is available in Postfix 3.0 and later.\n\nThis feature is not supported with smtp header/body checks.\n\nDISCARD optional text...\nClaim  successful  delivery  and silently discard the message.  Do not inspect the re‐\nmainder of the input message.  Log the optional text if  specified,  otherwise  log  a\ngeneric message.\n\nNote:  this  action  disables  further header or bodychecks inspection of the current\nmessage and affects all recipients.  To discard only one recipient without  discarding\nthe  entire  message, use the transport(5) table to direct mail to the discard(8) ser‐\nvice.\n\nThis feature is available in Postfix 2.0 and later.\n\nThis feature is not supported with smtp header/body checks.\n\nDUNNO  Pretend that the input line did not match any pattern,  and  inspect  the  next  input\nline. This action can be used to shorten the table search.\n\nFor backwards compatibility reasons, Postfix also accepts OK but it is (and always has\nbeen) treated as DUNNO.\n\nThis feature is available in Postfix 2.1 and later.\n\nFILTER transport:destination\nOverride the contentfilter parameter setting, and inspect the next input line.  After\nthe  message is queued, send the entire message through the specified external content\nfilter. The transport name specifies the first field of a mail delivery agent  defini‐\ntion  in  master.cf; the syntax of the next-hop destination is described in the manual\npage of the corresponding delivery agent.  More  information  about  external  content\nfilters is in the Postfix FILTERREADME file.\n\nNote  1: do not use $number regular expression substitutions for transport or destina‐\ntion unless you know that the information has a trusted origin.\n\nNote 2: this action overrides the main.cf contentfilter setting, and affects all  re‐\ncipients  of the message. In the case that multiple FILTER actions fire, only the last\none is executed.\n\nNote 3: the purpose of the FILTER command is to override message routing.  To override\nthe  recipient's  transport  but not the next-hop destination, specify an empty filter\ndestination (Postfix 2.7 and later), or specify a transport:destination that  delivers\nthrough  a different Postfix instance (Postfix 2.6 and earlier). Other options are us‐\ning the recipient-dependent transportmaps or the  sender-dependent  senderdependent‐‐\ndefaulttransportmaps features.\n\nThis feature is available in Postfix 2.0 and later.\n\nThis feature is not supported with smtp header/body checks.\n\nHOLD optional text...\nArrange  for  the  message  to be placed on the hold queue, and inspect the next input\nline.  The message remains on hold until someone either deletes it or releases it  for\ndelivery.  Log the optional text if specified, otherwise log a generic message.\n\nMail  that  is  placed on hold can be examined with the postcat(1) command, and can be\ndestroyed or released with the postsuper(1) command.\n\nNote: use \"postsuper -r\" to release mail that was kept on hold for a significant frac‐\ntion  of  $maximalqueuelifetime or $bouncequeuelifetime, or longer. Use \"postsuper\n-H\" only for mail that will not expire within a few delivery attempts.\n\nNote: this action affects all recipients of the message.\n\nThis feature is available in Postfix 2.0 and later.\n\nThis feature is not supported with smtp header/body checks.\n\nIGNORE Delete the current line from the input, and inspect the next input line. See STRIP for\nan alternative that logs the action.\n\nINFO optional text...\nLog  an  \"info:\" record with the optional text... (or log a generic text), and inspect\nthe next input line. This action is useful for routine logging or for debugging.\n\nThis feature is available in Postfix 2.8 and later.\n\nPASS optional text...\nLog a \"pass:\" record with the optional text... (or log a generic text), and  turn  off\nheader, body, and Milter inspection for the remainder of this message.\n\nNote: this feature relies on trust in information that is easy to forge.\n\nThis feature is available in Postfix 3.2 and later.\n\nThis feature is not supported with smtp header/body checks.\n\nPREPEND text...\nPrepend one line with the specified text, and inspect the next input line.\n\nNotes:\n\n•      The  prepended  text is output on a separate line, immediately before the input\nthat triggered the PREPEND action.\n\n•      The prepended text is not considered part of the input stream: it is  not  sub‐\nject to header/body checks or address rewriting, and it does not affect the way\nthat Postfix adds missing message headers.\n\n•      When prepending text before a message header line, the prepended text must  be‐\ngin with a valid message header label.\n\n•      This action cannot be used to prepend multi-line text.\n\nThis feature is available in Postfix 2.1 and later.\n\nThis feature is not supported with milterheaderchecks.\n\nREDIRECT user@domain\nWrite  a  message  redirection  request  to the queue file, and inspect the next input\nline. After the message is queued, it will be sent to the specified address instead of\nthe intended recipient(s).\n\nNote:  this action overrides the FILTER action, and affects all recipients of the mes‐\nsage. If multiple REDIRECT actions fire, only the last one is executed.\n\nThis feature is available in Postfix 2.1 and later.\n\nThis feature is not supported with smtp header/body checks.\n\nREPLACE text...\nReplace the current line with the specified text, and inspect the next input line.\n\nThis feature is available in Postfix 2.2 and later. The description below  applies  to\nPostfix 2.2.2 and later.\n\nNotes:\n\n•      When  replacing  a  message header line, the replacement text must begin with a\nvalid header label.\n\n•      The replaced text remains part of the input stream. Unlike the result from  the\nPREPEND  action,  a replaced message header may be subject to address rewriting\nand may affect the way that Postfix adds missing message headers.\n\nREJECT optional text...\nReject the entire message. Do not inspect the remainder of the input  message.   Reply\nwith  optional  text...  when  the  optional text is specified, otherwise reply with a\ngeneric error message.\n\nNote: this action disables further header or bodychecks  inspection  of  the  current\nmessage and affects all recipients.\n\nPostfix  version  2.3 and later support enhanced status codes.  When no code is speci‐\nfied at the beginning of optional text..., Postfix inserts a default  enhanced  status\ncode of \"5.7.1\".\n\nThis feature is not supported with smtp header/body checks.\n\nSTRIP optional text...\nLog  a  \"strip:\"  record with the optional text... (or log a generic text), delete the\ninput line from the input, and inspect the next input line. See IGNORE  for  a  silent\nalternative.\n\nThis feature is available in Postfix 3.2 and later.\n\nWARN optional text...\nLog a \"warning:\" record with the optional text... (or log a generic text), and inspect\nthe next input line. This action is useful for debugging and for testing a pattern be‐\nfore applying more drastic actions.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Empty  lines  never  match, because some map types mis-behave when given a zero-length search\nstring.  This limitation may be removed for regular expression tables in a future release.\n\nMany people overlook the main limitations of header and bodychecks rules.\n\n•      These rules operate on one logical message header or one body line at a time. A  deci‐\nsion made for one line is not carried over to the next line.\n\n•      If  text in the message body is encoded (RFC 2045) then the rules need to be specified\nfor the encoded form.\n\n•      Likewise, when message headers are encoded (RFC 2047) then the rules need to be speci‐\nfied for the encoded form.\n\nMessage  headers added by the cleanup(8) daemon itself are excluded from inspection. Examples\nof such message headers are From:, To:, Message-ID:, Date:.\n\nMessage headers deleted by the cleanup(8) daemon will be examined before  they  are  deleted.\nExamples are: Bcc:, Content-Length:, Return-Path:.\n",
            "subsections": []
        },
        "CONFIGURATION PARAMETERS": {
            "content": "bodychecks\nLookup tables with content filter rules for message body lines.  These filters see one\nphysical line at a time, in chunks of at most $linelengthlimit bytes.\n\nbodycheckssizelimit\nThe amount of content per message body  segment  (attachment)  that  is  subjected  to\n$bodychecks filtering.\n\nheaderchecks\n\nmimeheaderchecks (default: $headerchecks)\n\nnestedheaderchecks (default: $headerchecks)\nLookup  tables with content filter rules for message header lines: respectively, these\nare applied to the initial message headers (not including MIME headers), to  the  MIME\nheaders anywhere in the message, and to the initial headers of attached messages.\n\nNote:  these  filters  see  one  logical message header at a time, even when a message\nheader spans multiple lines. Message headers that are longer  than  $headersizelimit\ncharacters are truncated.\n\ndisablemimeinputprocessing\nWhile  receiving  mail, give no special treatment to MIME related message headers; all\ntext after the initial message headers is considered to be part of the  message  body.\nThis  means that headerchecks is applied to all the initial message headers, and that\nbodychecks is applied to the remainder of the message.\n\nNote: when used in this manner, bodychecks will process a multi-line  message  header\none line at a time.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Header pattern to block attachments with bad file name extensions.  For convenience, the PCRE\n/x flag is specified, so that there is no need to collapse the pattern into a single line  of\ntext.  The purpose of the [[:xdigit:]] sub-expressions is to recognize Windows CLSID strings.\n\n/etc/postfix/main.cf:\nheaderchecks = pcre:/etc/postfix/headerchecks.pcre\n\n/etc/postfix/headerchecks.pcre:\n/^Content-(Disposition|Type).*name\\s*=\\s*\"?([^;]*(\\.|=2E)(\nade|adp|asp|bas|bat|chm|cmd|com|cpl|crt|dll|exe|\nhlp|ht[at]|\ninf|ins|isp|jse?|lnk|md[betw]|ms[cipt]|nws|\n\\{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\\}|\nops|pcd|pif|prf|reg|sc[frt]|sh[bsm]|swf|\nvb[esx]?|vxd|ws[cfh]))(\\?=)?\"?\\s*(;|$)/x\nREJECT Attachment name \"$2\" may not end with \".$4\"\n\nBody pattern to stop a specific HTML browser vulnerability exploit.\n\n/etc/postfix/main.cf:\nbodychecks = regexp:/etc/postfix/bodychecks\n\n/etc/postfix/bodychecks:\n/^<iframe src=(3D)?cid:.* height=(3D)?0 width=(3D)?0>$/\nREJECT IFRAME vulnerability exploit\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "cleanup(8), canonicalize and enqueue Postfix message\npcretable(5), format of PCRE lookup tables\nregexptable(5), format of POSIX regular expression tables\npostconf(1), Postfix configuration utility\npostmap(1), Postfix lookup table management\npostsuper(1), Postfix janitor\npostcat(1), show Postfix queue file contents\nRFC 2045, base64 and quoted-printable encoding rules\nRFC 2047, message header encoding for non-ASCII text\n",
            "subsections": []
        },
        "README FILES": {
            "content": "Use \"postconf readmedirectory\" or \"postconf htmldirectory\" to locate this information.\nDATABASEREADME, Postfix lookup table overview\nCONTENTINSPECTIONREADME, Postfix content inspection overview\nBUILTINFILTERREADME, Postfix built-in content inspection\nBACKSCATTERREADME, blocking returned forged mail\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "The Secure Mailer license must be distributed with this software.\n\nAUTHOR(S)\nWietse Venema\nIBM T.J. Watson Research\nP.O. Box 704\nYorktown Heights, NY 10598, USA\n\nWietse Venema\nGoogle, Inc.\n111 8th Avenue\nNew York, NY 10011, USA\n\n\n\nHEADERCHECKS(5)",
            "subsections": []
        }
    },
    "summary": "headerchecks - Postfix built-in content inspection",
    "flags": [],
    "examples": [
        "Header pattern to block attachments with bad file name extensions.  For convenience, the PCRE",
        "/x flag is specified, so that there is no need to collapse the pattern into a single line  of",
        "text.  The purpose of the [[:xdigit:]] sub-expressions is to recognize Windows CLSID strings.",
        "/etc/postfix/main.cf:",
        "headerchecks = pcre:/etc/postfix/headerchecks.pcre",
        "/etc/postfix/headerchecks.pcre:",
        "/^Content-(Disposition|Type).*name\\s*=\\s*\"?([^;]*(\\.|=2E)(",
        "ade|adp|asp|bas|bat|chm|cmd|com|cpl|crt|dll|exe|",
        "hlp|ht[at]|",
        "inf|ins|isp|jse?|lnk|md[betw]|ms[cipt]|nws|",
        "\\{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\\}|",
        "ops|pcd|pif|prf|reg|sc[frt]|sh[bsm]|swf|",
        "vb[esx]?|vxd|ws[cfh]))(\\?=)?\"?\\s*(;|$)/x",
        "REJECT Attachment name \"$2\" may not end with \".$4\"",
        "Body pattern to stop a specific HTML browser vulnerability exploit.",
        "/etc/postfix/main.cf:",
        "bodychecks = regexp:/etc/postfix/bodychecks",
        "/etc/postfix/bodychecks:",
        "/^<iframe src=(3D)?cid:.* height=(3D)?0 width=(3D)?0>$/",
        "REJECT IFRAME vulnerability exploit"
    ],
    "see_also": [
        {
            "name": "cleanup",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/cleanup/8/json"
        },
        {
            "name": "pcretable",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pcretable/5/json"
        },
        {
            "name": "regexptable",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/regexptable/5/json"
        },
        {
            "name": "postconf",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/postconf/1/json"
        },
        {
            "name": "postmap",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/postmap/1/json"
        },
        {
            "name": "postsuper",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/postsuper/1/json"
        },
        {
            "name": "postcat",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/postcat/1/json"
        }
    ]
}