formail
TLDR
Extract headers from email
SYNOPSIS
formail [options] [output] < input
DESCRIPTION
formail is a mail processing utility from the procmail suite. It extracts headers, adds or modifies headers, splits mbox files, and helps generate automated replies.
The tool reads from stdin and writes to stdout, designed for use in pipelines and procmail recipes. It handles RFC 822 mail format intricacies.
PARAMETERS
-x header
Extract specific header.-X header
Extract header with continuation lines.-a header
Add header if not present.-A header
Add header always.-i header
Replace header.-u header
Make header unique.-r
Generate reply headers.-s command
Split and process with command.-b
Don't escape body "From " lines.-n count
Output only first n messages.
EXAMPLES
formail -s procmail < mbox
# Extract sender address
formail -x From: < message | head -1
# Add header for filtering
formail -a "X-Filtered: yes" < message
CAVEATS
Part of procmail suite which is no longer actively developed. MIME handling is limited. Complex headers may need careful extraction. Consider modern alternatives for new projects.
HISTORY
formail was developed by Stephen van den Berg as part of the procmail mail processing suite in the 1990s. While procmail is no longer actively maintained, formail remains useful for mail processing scripts.


