LinuxCommandLibrary

procmail

Mail delivery agent with recipe-based filtering

TLDR

Deliver mail using recipes

$ procmail < [email.txt]
copy
Test recipe file
$ procmail -m [VERBOSE=on] [recipe] < [email.txt]
copy
Specify maildir
$ procmail -d [maildir]
copy

SYNOPSIS

procmail [options] [parameters] [recipes...]

DESCRIPTION

procmail is a mail delivery agent and filtering program. It sorts incoming mail into folders based on rules defined in .procmailrc, enabling automatic mail organization.
The tool can filter spam, sort mailing lists, forward mail, and execute scripts based on message content.

PARAMETERS

-d maildir

Delivery directory.
-m [params]
Use as filter.
-t
Fail if not run as daemon.
-v
Verbose mode.
-f fromline
Set From line.

CONFIGURATION

~/.procmailrc

User-level recipe file defining mail filtering rules, delivery actions, and variable settings like MAILDIR and LOGFILE.
~/.forward
Mail forwarding file that pipes incoming mail to procmail, typically containing `"|IFS=' ' && exec /usr/bin/procmail -f- || exit 75"`.
/etc/procmailrc
System-wide recipe file applied to all users before individual .procmailrc rules.

RECIPE FORMAT

$ :0 [flags] [:lockfile]
* condition
action
copy
Flags: H=header, B=body, h=header to pipe, b=body to pipe

CAVEATS

Complex recipe syntax. Security requires careful configuration. Largely superseded by server-side filters. Maintenance can be tricky.

HISTORY

procmail was written by Stephen van den Berg starting in 1990. It became the standard Unix mail filtering tool, though its usage has declined with webmail and server-side filtering. It's still used for advanced local mail processing.

SEE ALSO

fetchmail(1), formail(1), maildir(5), sieve(5)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community