{{Short description|Email server software component}} {{More citations needed|date=April 2023}} {{Lowercase title}} {{Infobox software | name = procmail | author = Stephen R. van den Berg | developer = Philip A. Guenther | released = December 7, 1990 | latest release version = 3.24 | latest release date = March 2, 2022 | operating system = Any Unix-like | platform = Cross-platform | genre = Mail filter | license = GPL or Artistic License | discontinued = yes | website = {{webarchive |url=https://web.archive.org/web/20151013184044/http://www.procmail.org |title=procmail.org|nolink=1}} }}
'''procmail''' is an email server software component — specifically, a message delivery agent (MDA). It was one of the earliest mail filter programs. It is typically used in Unix-like mail systems, using the mbox and Maildir storage formats.
procmail was first developed in 1990, by Stephen R. van den Berg.<ref name="README"/> Philip Guenther took over maintainership for a number of years, but relinquished the role in 2014.<ref name="openbsd-ports-marc"/> The software remained unmaintained for several years, and was believed to be defunct.<ref name="death"/> In 2020 May, Stephen van den Berg resumed maintenance again.<ref name="debbug"/> The program has since seen multiple releases and bug-fixes.
== Uses ==
The most common use case for procmail is to filter mail into different mailboxes, based on criteria such as sender address, subject keywords, and/or mailing list address.<ref name="GtLIaA"/><ref name="qmailbook"/>
Another use is to let procmail call an external spam filter program, such as SpamAssassin. This method can allow for spam to be filtered or deleted.
The procmail developers have built a mailing list manager called ''SmartList''<ref>[https://github.com/procmail-org/SmartList SmartList repo]</ref> on top of procmail.<ref>[https://zhilianghu.github.io/SmartList/ SmartList Documentations]</ref>
Procmail is an early example of a mail filtering tool and language. It is a data-driven programming language, similar to earlier line-oriented languages such as sed and AWK.
== Operation ==
procmail reads mail messages given to it on standard input, delivering or otherwise dispositioning each one. procmail is typically not invoked directly by the user. Rather, some other mail program will call upon procmail to deliver a message according to the user's wishes. Message transfer agents (MTAs), such as Sendmail or Postfix), can be configured to use procmail to deliver all mail. A mail retrieval agent such as fetchmail can invoke procmail as needed. The companion tool ''formail'' allows procmail to be applied to mail already in a mailbox.
procmail's behavior is controlled by a config file (by default, {{mono|.procmailrc}} in the user's home directory) containing one or more ''recipes'', read in order. Each recipe consists of a ''mode'', zero or more ''conditions'', and an ''action''.
Conditions are usually extended regular expressions, although there are other forms. A recipe's action is taken only if all the conditions match (logical AND). If no conditions is given, the recipe is unconditional and the action always runs.
The action specifies what is to be done with the message, such as deliver it to a particular mailbox, or discard it. A recipe and its action can be ''delivering'' or ''non-delivering''. Processing of a given message stops with the first delivering recipe (unless the recipe's mode flag specifies otherwise).
== Example ==
A simple {{mono|.procmailrc}} config file might look like this:
MAILDIR=$HOME/mail DEFAULT=$MAILDIR/inbox :0: * ^List-Id: .*<foo-announce@lists.example.com> foo-announce
The above routes mail from a hypothetical mailing list to a separate mailbox called {{mono|foo-announce}}, while delivering all other mail to the {{mono|inbox}} mailbox, both located under the {{mono|$HOME/mail/}} directory.
== Criticism ==
By default, procmail will "bounce" undeliverable mail back to the sender, or discard it entirely. A mistake in the config file can result in all mail being rejected or discarded.
The configuration file format is sometimes regarded as cryptic.
procmail is not well-suited for processing mail involving Multipurpose Internet Mail Extensions (MIME). It cannot decode or recognize MIME-specific headers or international characters.
For approximately ten years, procmail was not maintained, and multiple serious security vulnerabilities<ref name="cvedetails-procmail"/> were discovered in the intervening time span<ref name="death"/> (since fixed).
== See also ==
{{Portal|Free and open-source software}}
=== Mail architecture === * Email * Message transfer agent * Message delivery agent * Mail retrieval agent * Simple Mail Transfer Protocol * List of mailing list software
=== Similar programs and technologies ===
* fdm (fetch, filter and deliver mail) * maildrop * Dovecot * Sieve mail filtering language
== References == <references>
<ref name="GtLIaA">{{cite book |url = https://books.google.com/books?id=jQE-iUCjUKAC&q=procmail&pg=PA145 |title = Guide to Linux Installation and Administration |first1 = Nicholas |last1 = Wells |first2 = Michael |last2 = Jang |date = 3 October 2018 |publisher = Cengage Learning EMEA |isbn = 9780619000974 |via = Google Books }}</ref>
<ref name="qmailbook">{{cite book |url = https://books.google.com/books?id=AYAjb7Y9HfMC&q=procmail&pg=PT52 |title = qmail: Managing Unix-Based Mail Systems |first = John |last = Levine |date = 24 March 2004 |publisher = O'Reilly Media, Inc. |isbn = 9780596552121 |via = Google Books }}</ref>
<ref name="death">{{cite web |last = Willis |first = Nathan |title = Reports of procmail's death are not terribly exaggerated |url = https://lwn.net/Articles/416901/ |publisher = Linux Weekly News |date = 24 November 2010 |access-date = 27 October 2013 }}</ref>
<ref name="openbsd-ports-marc">{{cite mailing list |last1 = Gunther |first1 = Philip |title = please remove the procmail port |url = http://marc.info/?l=openbsd-ports&m=141634350915839&w=2 |publisher = OpenBSD |mailing-list = ports@ |date = 2014-11-18 |access-date = 2019-02-25 }}</ref>
<ref name="cvedetails-procmail">{{cite web |title = CVEdetails: Procmail Vulnerabilities |url = https://www.cvedetails.com/vulnerability-list/vendor_id-225/product_id-392/Procmail-Procmail.html |publisher = CVEdetails.com |date = 2018-02-03 |access-date = 2020-05-02 }}</ref>
<ref name="README">{{cite web |title = README |url = https://github.com/BuGlessRB/procmail/blob/master/README |date = 2022-03-02 |access-date = 2022-04-26 |quote = Copyright (c) 1990-2022, S.R. van den Berg, The Netherlands. Copyright (c) 1997-2005, Philip Guenther, The United States of America. }}</ref>
<ref name="debbug">{{cite web |title = #1006633: procmail is unmaintained upstream |author = Stephen R. van den Berg |url = https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1006633#24 |date = 2022-03-02 |access-date = 2022-04-26 |quote = As of May 2020, the dormant state of procmail upstream maintenance has been changed back to active. As Santiago Vila can attest to, I have taken up active maintenance of procmail again since the past two years ... }}</ref>
</references>
== Further reading ==
* {{cite book | last=McCarthy | first=Martin | date=November 2001 | title=The Procmail Companion | publisher=Addison-Wesley | isbn=978-0201737905 }}
== External links ==
* {{cite web |url = https://github.com/BuGlessRB/procmail |title = GitHub - BuGlessRB/procmail: The mail sorting program }} — Current source code repository and distribution point * {{cite web |url = http://www.procmail.org/ |archive-url = https://web.archive.org/web/20151013184044/http://www.procmail.org/ |title = Procmail Homepage |archive-date = 2015-10-13 }} — Procmail homepage, as it appeared when it was working * {{cite web |url = http://procmail.markmail.org/ |title = Procmail Home - MarkMail - Community libraries }} — Searchable archives of the procmail mailing list
Category:Mail delivery agents Category:Cross-platform software