OnWorks favicon

formail - Online in the Cloud

Run formail in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command formail that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator



formail - mail (re)formatter


formail [+skip] [-total] [-bczfrktedqBY] [-p prefix]
[-D maxlen idcache]
[-l folder]
[-x headerfield] [-X headerfield]
[-a headerfield] [-A headerfield]
[-i headerfield] [-I headerfield]
[-u headerfield] [-U headerfield]
[-R oldfield newfield]
[-n [maxprocs ]] [-m minfields] [-s [command [arg ...]]]
formail -v


formail is a filter that can be used to force mail into mailbox format, perform `From '
escaping, generate auto-replying headers, do simple header munging/extracting or split up
a mailbox/digest/articles file. The mail/mailbox/article contents will be expected on

If formail is supposed to determine the sender of the mail, but is unable to find any, it
will substitute `foo@bar'.

If formail is started without any command line options, it will force any mail coming from
stdin into mailbox format and will escape all bogus `From ' lines with a `>'.


-v Formail will print its version number and exit.

-b Don't escape any bogus mailbox headers (i.e., lines starting with `From ').

-p prefix
Define a different quotation prefix. If unspecified it defaults to `>'.

-Y Assume traditional Berkeley mailbox format, ignoring any Content-Length: fields.

-c Concatenate continued fields in the header. Might be convenient when postprocessing
mail with standard (line oriented) text utilities.

-z Ensure a whitespace exists between field name and content. Zap fields which contain
only a single whitespace character. Zap leading and trailing whitespace on fields
extracted with -x.

-f Force formail to simply pass along any non-mailbox format (i.e., don't generate a
`From ' line as the first line).

-r Generate an auto-reply header. This will normally throw away all the existing fields
(except X-Loop:) in the original message, fields you wish to preserve need to be
named using the -i option. If you use this option in conjunction with -k, you can
prevent the body from being `escaped' by also specifying -b.

-k When generating the auto-reply header or when extracting fields, keep the body as

-t Trust the sender to have used a valid return address in his header. This causes
formail to select the header sender instead of the envelope sender for the reply.
This option should be used when generating auto-reply headers from news articles or
when the sender of the message is expecting a reply.

-s The input will be split up into separate mail messages, and piped into a program one
by one (a new program is started for every part). -s has to be the last option
specified, the first argument following it is expected to be the name of a program,
any other arguments will be passed along to it. If you omit the program, then
formail will simply concatenate the split mails on stdout again. See FILENO.

-n [maxprocs]
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
messages 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
before 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

-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

-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
occurrences 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 the first skip messages while splitting.

Output at most total messages while splitting.


When renaming, removing, or extracting fields, partial fieldnames may be used to specify
all fields that start with the specified value.

By default, when generating an auto-reply header procmail selects the envelope sender from
the input message. This is correct for vacation messages and other automatic replies
regarding the routing or delivery of the original message. If the sender is expecting a
reply or the reply is being generated in response to the contents of the original message
then the -t option should be used.

RFC822, the original standard governing the format of Internet mail messages, did not
specify whether Resent header fields (those that begin with `Resent-', such as
`Resent-From:') should be considered when generating a reply. Since then, the recommended
usage of the Resent headers has evolved to consider them as purely informational and not
for use when generating a reply. This has been codified in RFC2822, the new Internet
Message Format standard, which states in part:

Resent fields are used to identify a message as having been reintroduced into the
transport system by a user. The purpose of using resent fields is to have the
message appear to the final recipient as if it were sent directly by the original
sender, with all of the original fields remaining the same....They MUST NOT be used
in the normal processing of replies or other such automatic actions on messages.

While formail now ignores Resent headers when generating header replies, versions of
formail prior to 3.14 gave such headers a high precedence. If the old behavior is needed
for established applications it can be specified by calling formail with the option `-a
Resent-' in addition to the -r and -t options. This usage is deprecated and should not be
used in new applications.


While splitting, formail assigns the message number currently being output to this
variable. By presetting FILENO, you can change the initial message number being used
and the width of the zero-padded output. If FILENO is unset it will default to 000.
If FILENO is non-empty and does not contain a number, FILENO generation is disabled.


To split up a digest one usually uses:
formail +1 -ds >>the_mailbox_of_your_choice
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 <old_mailbox >>new_mailbox

Or, if you have a very tolerant mailer:
formail -a Date: -ds <old_mailbox >>new_mailbox

To extract the header from a message:
formail -X ""
sed -e '/^$/ q'

To extract the body from a message:
formail -I ""
sed -e '1,/^$/ d'

Use formail online using onworks.net services

Free Servers & Workstations

Download Windows & Linux apps

  • 1
    A set of Python extension modules that
    wrap the cross-platform GUI classes from
    wxWidgets.. Audience: Developers. User
    interface: X Window System (X11), Win32 ...
    Download wxPython
  • 2
    This is the Total War pack file manager
    project, starting from version 1.7. A
    short introduction into Warscape
    modding: ...
    Download packfilemanager
  • 3
    A network traffic tool for measuring
    TCP and UDP performance with metrics
    around both throughput and latency. The
    goals include maintaining an active
    iperf cod...
    Download IPerf2
  • 4
    fre:ac - free audio converter
    fre:ac - free audio converter
    fre:ac is a free audio converter and CD
    ripper for various formats and encoders.
    It features MP3, MP4/M4A, WMA, Ogg
    Vorbis, FLAC, AAC, and Bonk format
    support, ...
    Download fre:ac - free audio converter
  • 5
    Matplotlib is a comprehensive library
    for creating static, animated, and
    interactive visualizations in Python.
    Matplotlib makes easy things easy and
    hard thing...
    Download Matplotlib
  • 6
    Write your chatbot logic once and
    connect it to one of the available
    messaging services, including Amazon
    Alexa, Facebook Messenger, Slack,
    Telegram or even yo...
    Download BotMan
  • More »

Linux commands