formail [options]

Filter standard input into mailbox format. Useful for splitting mail digests or passing the contents of a mail file to another program, such as a spam filter, for additional processing. If no sender is apparent, provide the sender foo@bar. By default, escape bogus From lines with >.



Do not split first skip messages.


Stop after splitting total messages.

-a headerfield

Append headerfield to header, unless it already exists. If header-field is Message-ID or Resent-Message-ID with no contents, generate a unique message ID.

-A headerfield

Append headerfield whether or not it already exists.


Do not escape bogus From lines.


Assume that input is in BABYL rmail format.


When header fields are more than one line long, concatenate the lines.


Do not assume that input must be in strict mailbox format. This option disables recognition of the Content-Length field so you can split digests or use nonstandard mailbox formats.

-D maxlen idcache

Remember old message IDs (in idcache, which will grow no larger than approximately maxlen). When splitting, refuse to output duplicate messages. Otherwise, return true on discovering a duplicate. With -r, look at the sender’s mail address instead of the message ID.


Allow messages to begin one immediately after the other; do not require empty space between them.


Do not edit non-mailbox-format lines. By default, formail prepends From to such lines.

-i headerfield

Like -A, but rename each existing headerfield

Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.