{
    "content": [
        {
            "type": "text",
            "text": "# formail (man)\n\n## NAME\n\nformail - mail (re)formatter\n\n## SYNOPSIS\n\nformail [+skip] [-total] [-bczfrktedqBY] [-p prefix]\n[-D maxlen idcache]\n[-l folder]\n[-x headerfield] [-X headerfield]\n[-a headerfield] [-A headerfield]\n[-i headerfield] [-I headerfield]\n[-u headerfield] [-U headerfield]\n[-R oldfield newfield]\n[-n [maxprocs ]] [-m minfields] [-s [command [arg ...]]]\nformail -v\n\n## DESCRIPTION\n\nformail  is  a filter that can be used to force mail into mailbox format, perform `From ' es-\ncaping, generate auto-replying headers, do simple header munging/extracting  or  split  up  a\nmailbox/digest/articles file.  The mail/mailbox/article contents will be expected on stdin.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (2 subsections)\n- **NOTES**\n- **ENVIRONMENT**\n- **EXAMPLES**\n- **SEE ALSO**\n- **DIAGNOSTICS**\n- **WARNINGS**\n- **BUGS**\n- **MISCELLANEOUS**\n- **SOURCE**\n- **MAILINGLIST**\n- **AUTHORS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "formail",
        "section": "",
        "mode": "man",
        "summary": "formail - mail (re)formatter",
        "synopsis": "formail [+skip] [-total] [-bczfrktedqBY] [-p prefix]\n[-D maxlen idcache]\n[-l folder]\n[-x headerfield] [-X headerfield]\n[-a headerfield] [-A headerfield]\n[-i headerfield] [-I headerfield]\n[-u headerfield] [-U headerfield]\n[-R oldfield newfield]\n[-n [maxprocs ]] [-m minfields] [-s [command [arg ...]]]\nformail -v",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "-n",
                "long": null,
                "arg": null,
                "description": "Tell formail not to wait for every program to finish before starting the next (causes splits to be processed in parallel). Maxprocs optionally specifies an upper limit on the number of concurrently running processes. -e Do not require empty lines to be preceding the header of a new message (i.e., the mes- sages could start on every line). -d Tell formail that the messages it is supposed to split need not be in strict mailbox format (i.e., allows you to split digests/articles or non-standard mailbox formats). This disables recognition of the Content-Length: field. -l folder Generate a log summary in the same style as procmail. This includes the entire \"From \" line, the Subject: header field, the folder, and the size of the message in bytes. The mailstat command can be used to summarize logs in this format. -B Makes formail assume that it is splitting up a BABYL rmail file. -m minfields Allows you to specify the number of consecutive headerfields formail needs to find be- fore it decides it found the start of a new message, it defaults to 2. -q Tells formail to (still detect but) be quiet about write errors, duplicate messages and mismatched Content-Length: fields. This option is on by default, to make it display the messages use -q-. -D maxlen idcache Formail will detect if the Message-ID of the current message has already been seen using an idcache file of approximately maxlen size. If not splitting, it will return success if a duplicate has been found. If splitting, it will not output duplicate messages. If used in conjunction with -r, formail will look at the mail address of the envelope sender instead at the Message-ID. -x headerfield Extract the contents of this headerfield from the header. Line continuations will be left intact; if you want the value on a single line then you'll also need the -c option. -X headerfield Same as -x, but also preserves/includes the field name. -a headerfield Append a custom headerfield onto the header; but only if a similar field does not exist yet. If you specify either one of the field names Message-ID: or Resent-Message-ID: with no field contents, then formail will generate a unique message-ID for you. -A headerfield Append a custom headerfield onto the header in any case. -i headerfield Same as -A, except that any existing similar fields are renamed by prepending an ``Old-'' prefix. If headerfield consists only of a field-name, it will not be appended. -I headerfield Same as -i, except that any existing similar fields are simply removed. If headerfield consists only of a field-name, it effectively deletes the field. -u headerfield Make the first occurrence of this field unique, and thus delete all subsequent occur- rences of it. -U headerfield Make the last occurrence of this field unique, and thus delete all preceding occurrences of it. -R oldfield newfield Renames all occurrences of the fieldname oldfield into newfield. +skip Skip the first skip messages while splitting."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Output at most total messages while splitting."
            }
        ],
        "examples": [
            "To split up a digest one usually uses:",
            "formail +1 -ds >>themailboxofyourchoice",
            "or",
            "formail +1 -ds procmail",
            "To remove all Received: fields from the header:",
            "formail -I Received:",
            "To remove all fields except From: and Subject: from the header:",
            "formail -k -X From: -X Subject:",
            "To supersede the Reply-To: field in a header you could use:",
            "formail -i \"Reply-To: foo@bar\"",
            "To convert a non-standard mailbox file into a standard mailbox file you can use:",
            "formail -ds <oldmailbox >>newmailbox",
            "Or, if you have a very tolerant mailer:",
            "formail -a Date: -ds <oldmailbox >>newmailbox",
            "To extract the header from a message:",
            "formail -X \"\"",
            "or",
            "sed -e '/^$/ q'",
            "To extract the body from a message:",
            "formail -I \"\"",
            "or",
            "sed -e '1,/^$/ d'"
        ],
        "see_also": [
            {
                "name": "mail",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/mail/1/json"
            },
            {
                "name": "sendmail",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/sendmail/8/json"
            },
            {
                "name": "procmail",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/procmail/1/json"
            },
            {
                "name": "sed",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/sed/1/json"
            },
            {
                "name": "sh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/sh/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 37,
                "subsections": [
                    {
                        "name": "-n [maxprocs]",
                        "lines": 70,
                        "flag": "-n",
                        "arg": "[maxprocs]"
                    },
                    {
                        "name": "-total",
                        "lines": 2
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "ENVIRONMENT",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 30,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DIAGNOSTICS",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "WARNINGS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 16,
                "subsections": []
            },
            {
                "name": "MISCELLANEOUS",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "SOURCE",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "MAILINGLIST",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "formail - mail (re)formatter\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "formail [+skip] [-total] [-bczfrktedqBY] [-p prefix]\n[-D maxlen idcache]\n[-l folder]\n[-x headerfield] [-X headerfield]\n[-a headerfield] [-A headerfield]\n[-i headerfield] [-I headerfield]\n[-u headerfield] [-U headerfield]\n[-R oldfield newfield]\n[-n [maxprocs ]] [-m minfields] [-s [command [arg ...]]]\nformail -v\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "formail  is  a filter that can be used to force mail into mailbox format, perform `From ' es-\ncaping, generate auto-replying headers, do simple header munging/extracting  or  split  up  a\nmailbox/digest/articles file.  The mail/mailbox/article contents will be expected on stdin.\n\nIf  formail  is  supposed  to determine the sender of the mail, but is unable to find any, it\nwill substitute `foo@bar'.\n\nIf formail is started without any command line options, it will force any  mail  coming  from\nstdin into mailbox format and will escape all bogus `From ' lines with a `>'.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "-v   Formail will print its version number and exit.\n\n-b   Don't escape any bogus mailbox headers (i.e., lines starting with `From ').\n\n-p prefix\nDefine a different quotation prefix.  If unspecified it defaults to `>'.\n\n-Y   Assume traditional Berkeley mailbox format, ignoring any Content-Length: fields.\n\n-c   Concatenate  continued  fields  in  the header.  Might be convenient when postprocessing\nmail with standard (line oriented) text utilities.\n\n-z   Ensure a whitespace exists between field name and content.   Zap  fields  which  contain\nonly  a  single whitespace character.  Zap leading and trailing whitespace on fields ex-\ntracted with -x.\n\n-f   Force formail to simply pass along any non-mailbox format (i.e., don't generate a  `From\n' line as the first line).\n\n-r   Generate  an  auto-reply  header.  This will normally throw away all the existing fields\n(except X-Loop:) in the original message, fields you wish to preserve need to  be  named\nusing the -i option.  If you use this option in conjunction with -k, you can prevent the\nbody from being `escaped' by also specifying -b.\n\n-k   When generating the auto-reply header or when extracting fields, keep the body as well.\n\n-t   Trust the sender to have used a valid return address in his header.  This causes formail\nto  select  the header sender instead of the envelope sender for the reply.  This option\nshould be used when generating auto-reply headers from news articles or when the  sender\nof the message is expecting a reply.\n\n-s   The  input will be split up into separate mail messages, and piped into a program one by\none (a new program is started for every part).  -s has to be the last option  specified,\nthe first argument following it is expected to be the name of a program, any other argu-\nments will be passed along to it.  If you omit the program,  then  formail  will  simply\nconcatenate the split mails on stdout again.  See FILENO.\n",
                "subsections": [
                    {
                        "name": "-n [maxprocs]",
                        "content": "Tell  formail  not  to wait for every program to finish before starting the next (causes\nsplits to be processed in parallel).  Maxprocs optionally specifies an  upper  limit  on\nthe number of concurrently running processes.\n\n-e   Do  not require empty lines to be preceding the header of a new message (i.e.,  the mes-\nsages could start on every line).\n\n-d   Tell formail that the messages it is supposed to split need not  be  in  strict  mailbox\nformat  (i.e.,  allows  you  to split digests/articles or non-standard mailbox formats).\nThis disables recognition of the Content-Length: field.\n\n-l folder\nGenerate a log summary in the same style as procmail.  This includes the entire \"From  \"\nline,  the Subject: header field, the folder, and the size of the message in bytes.  The\nmailstat command can be used to summarize logs in this format.\n\n-B   Makes formail assume that it is splitting up a BABYL rmail file.\n\n-m minfields\nAllows you to specify the number of consecutive headerfields formail needs to  find  be-\nfore it decides it found the start of a new message, it defaults to 2.\n\n-q   Tells  formail to (still detect but) be quiet about write errors, duplicate messages and\nmismatched Content-Length: fields.  This option is on by default, to make it display the\nmessages use -q-.\n\n-D maxlen idcache\nFormail will detect if the Message-ID of the current message has already been seen using\nan idcache file of approximately maxlen size.  If not splitting, it will return  success\nif a duplicate has been found.  If splitting, it will not output duplicate messages.  If\nused in conjunction with -r, formail will look at  the  mail  address  of  the  envelope\nsender instead at the Message-ID.\n\n-x headerfield\nExtract  the  contents  of this headerfield from the header.  Line continuations will be\nleft intact; if you want the value on a single line then you'll also need the -c option.\n\n-X headerfield\nSame as -x, but also preserves/includes the field name.\n\n-a headerfield\nAppend a custom headerfield onto the header; but only if a similar field does not  exist\nyet.   If  you  specify  either one of the field names Message-ID: or Resent-Message-ID:\nwith no field contents, then formail will generate a unique message-ID for you.\n\n-A headerfield\nAppend a custom headerfield onto the header in any case.\n\n-i headerfield\nSame as -A, except that any  existing  similar  fields  are  renamed  by  prepending  an\n``Old-'' prefix.  If headerfield consists only of a field-name, it will not be appended.\n\n-I headerfield\nSame  as -i, except that any existing similar fields are simply removed.  If headerfield\nconsists only of a field-name, it effectively deletes the field.\n\n-u headerfield\nMake the first occurrence of this field unique, and thus delete  all  subsequent  occur-\nrences of it.\n\n-U headerfield\nMake the last occurrence of this field unique, and thus delete all preceding occurrences\nof it.\n\n-R oldfield newfield\nRenames all occurrences of the fieldname oldfield into newfield.\n\n+skip\nSkip the first skip messages while splitting.\n",
                        "flag": "-n",
                        "arg": "[maxprocs]"
                    },
                    {
                        "name": "-total",
                        "content": "Output at most total messages while splitting.\n"
                    }
                ]
            },
            "NOTES": {
                "content": "Calling up formail with the -h or -? options will cause it to  display  a  command-line  help\npage.\n",
                "subsections": []
            },
            "ENVIRONMENT": {
                "content": "FILENO\nWhile splitting, formail assigns the message number currently being output to this vari-\nable.   By  presetting  FILENO, you can change the initial message number being used and\nthe width of the zero-padded output.  If FILENO is unset it will  default  to  000.   If\nFILENO is non-empty and does not contain a number, FILENO generation is disabled.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "To split up a digest one usually uses:\nformail +1 -ds >>themailboxofyourchoice\nor\nformail +1 -ds procmail\n\nTo remove all Received: fields from the header:\nformail -I Received:\n\nTo remove all fields except From: and Subject: from the header:\nformail -k -X From: -X Subject:\n\nTo supersede the Reply-To: field in a header you could use:\nformail -i \"Reply-To: foo@bar\"\n\nTo convert a non-standard mailbox file into a standard mailbox file you can use:\nformail -ds <oldmailbox >>newmailbox\n\nOr, if you have a very tolerant mailer:\nformail -a Date: -ds <oldmailbox >>newmailbox\n\nTo extract the header from a message:\nformail -X \"\"\nor\nsed -e '/^$/ q'\n\nTo extract the body from a message:\nformail -I \"\"\nor\nsed -e '1,/^$/ d'\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "mail(1), sendmail(8), procmail(1), sed(1), sh(1), RFC822, RFC2822, RFC1123\n",
                "subsections": []
            },
            "DIAGNOSTICS": {
                "content": "Can't fork             Too many processes on this machine.\n\nContent-Length: field exceeds actual length by nnn bytes\nThe  Content-Length:  field  in the header specified a length that was\nlonger than the actual body.  This causes this  message  to  absorb  a\nnumber of subsequent messages following it in the same mailbox.\n\nCouldn't write to stdout\nThe program that formail was trying to pipe into didn't accept all the\ndata formail sent to it; this diagnostic can be suppressed by  the  -q\noption.\n\nDuplicate key found: x The  Message-ID  or sender x in this message was found in the idcache;\nthis diagnostic can be suppressed by the -q option.\n\nFailed to execute \"x\"  Program not in path, or not executable.\n\nFile table full        Too many open files on this machine.\n\nInvalid field-name: \"x\"\nThe specified field-name \"x\" contains control characters, or cannot be\na partial field-name for this option.\n",
                "subsections": []
            },
            "WARNINGS": {
                "content": "You can save yourself and others a lot of grief if you try to avoid using this autoreply fea-\nture on mails coming through mailinglists.  Depending on the  format  of  the  incoming  mail\n(which  in  turn  depends on both the original sender's mail agent and the mailinglist setup)\nformail could decide to generate an autoreply header that replies to the list.\n\nIn the tradition of UN*X utilities, formail will do exactly what you ask it to,  even  if  it\nresults  in  a  non-RFC822  compliant  message.  In particular, formail will let you generate\nheader fields whose name ends in a space instead of a colon.  While this is correct  for  the\nleading  `From  '  line, that line is not a header field so much as the message separator for\nthe mbox mailbox format.  Multiple occurrences of such a line or any other  colonless  header\nfield will be considered by many mail programs, including formail itself, as the beginning of\na new message.  Others will consider the message to be corrupt.  Because of this, you  should\nnot  use the -i option with the `From ' line as the resulting renamed line, `Old-From ', will\nprobably not do what you want it to.  If you want to save the original `From '  line,  rename\nit with the -R option to a legal header field such as `X-From:'.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "When  formail  has  to  generate  a leading `From ' line it normally will contain the current\ndate.  If formail is given the option `-a Date:', it will use the date from the `Date:' field\nin  the header (if present).  However, since formail copies it verbatim, the format will dif-\nfer from that expected by most mail readers.\n\nIf formail is instructed to delete or rename the leading `From ' line, it will not  automati-\ncally  regenerate  it  as  usual.  To force formail to regenerate it in this case, include -a\n'From '.\n\nIf formail is not called as the first program in a pipe and it is told to split up the  input\nin  several messages, then formail will not terminate until the program it receives the input\nfrom closes its output or terminates itself.\n\nIf formail is instructed to generate an autoreply mail, it will never put more than  one  ad-\ndress in the `To:' field.\n",
                "subsections": []
            },
            "MISCELLANEOUS": {
                "content": "Formail is eight-bit clean.\n\nWhen  formail  has to determine the sender's address, every RFC822 conforming mail address is\nallowed.  Formail will always strip down the address to its minimal form (deleting  excessive\ncomments and whitespace).\n\nThe regular expression that is used to find `real' postmarks is:\n\"\\n\\nFrom [\\t ]*[^\\t\\n ]+[\\t ]+[^\\n\\t ]\"\n\nIf  a  Content-Length:  field is found in a header, formail will copy the number of specified\nbytes in the body verbatim before resuming the regular scanning for message  boundaries  (ex-\ncept when splitting digests or Berkeley mailbox format is assumed).\n\nAny  header lines immediately following the leading `From ' line that start with `>From ' are\nconsidered to be a continuation of the `From ' line.  If instructed to  rename  the  `From  '\nline, formail will change each leading `>' into a space, thereby transforming those lines in-\nto normal RFC822 continuations.\n",
                "subsections": []
            },
            "SOURCE": {
                "content": "This  program  is  part  of  the  procmail  mail-processing-package  (v3.23pre)  available at\nhttp://www.procmail.org/ or ftp.procmail.org in pub/procmail/.\n",
                "subsections": []
            },
            "MAILINGLIST": {
                "content": "There exists a mailinglist for questions relating to any program in the procmail package:\n<procmail-users@procmail.org>\nfor submitting questions/answers.\n<procmail-users-request@procmail.org>\nfor subscription requests.\n\nIf you would like to stay informed about new versions and official patches send  a  subscrip-\ntion request to\nprocmail-announce-request@procmail.org\n(this is a readonly list).\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "Stephen R. van den Berg\n<srb@cuci.nl>\nPhilip A. Guenther\n<guenther@sendmail.com>\n\nBuGless                                     2001/08/04                                 FORMAIL(1)",
                "subsections": []
            }
        }
    }
}