CLEANUP(8)
β¨ CLEANUP π
β the cleanup(8) manual page, but make it make sense β¨
okay bestie, listen. this is cleanup(8) from the System Manager's Manual, and it's genuinely one of the most important little gremlins in the whole Postfix family. she's not flashy. she's just that girl. let's get into it π«Ά
πΈ NAME πΈ
cleanup β canonicalize and enqueue Postfix message π
π SYNOPSIS π
cleanup [generic Postfix daemon options]
π¦ DESCRIPTION π¦
The cleanup(8) daemon processes inbound mail, inserts it into the incoming mail queue, and informs the queue manager that it has arrived. she's basically the receptionist, the bouncer, the makeup artist and the filing clerk all at once. no cap. π
The cleanup(8) daemon performs the following transformations:
- Insert missing message headers:
(Resent-) From:,To:,Message-Id:, andDate:. This is enabled with thelocal_header_rewrite_clientsandalways_add_missing_headersparameter settings. - Transform envelope and header addresses to the standard
user@fully-qualified-domainform that is expected by other Postfix programs. This task depends on thetrivial-rewrite(8)daemon. The header transformation is enabled with thelocal_header_rewrite_clientsparameter setting. - Eliminate duplicate envelope recipient addresses. This is enabled with the
duplicate_filter_limitparameter setting. - Remove message headers:
Bcc,Content-Length,Resent-Bcc,Return-Path. This is enabled with themessage_drop_headersparameter setting. - Optionally, rewrite all envelope and header addresses according to the mappings specified in the
canonical(5)lookup tables. The header transformation is enabled with thelocal_header_rewrite_clientsparameter setting. - Optionally, masquerade envelope sender addresses and message header addresses (i.e. strip host or domain information below all domains listed in the
masquerade_domainsparameter, except for user names listed inmasquerade_exceptions). By default, address masquerading does not affect envelope recipients. The header transformation is enabled with thelocal_header_rewrite_clientsparameter setting. - Optionally, expand envelope recipients according to information found in the
virtual_alias_mapslookup tables.
The cleanup(8) daemon performs sanity checks on the content of each message. When it finds a problem, by default it returns a diagnostic status to the cleanup service client, and leaves it up to the client to deal with the problem. Alternatively, the client can request the cleanup(8) daemon to bounce the message back to the sender in case of trouble. so she checks the vibe AND she snitches. iconic behavior honestly. π
π STANDARDS π
- RFC 822 (ARPA Internet Text Messages)
- RFC 2045 (MIME: Format of Internet Message Bodies)
- RFC 2046 (MIME: Media Types)
- RFC 2822 (Internet Message Format)
- RFC 3463 (Enhanced Status Codes)
- RFC 3464 (Delivery status notifications)
- RFC 5322 (Internet Message Format)
- RFC 8689 (TLS-Required: message header)
π DIAGNOSTICS π
Problems and transactions are logged to syslogd(8) or postlogd(8). she's telling on you, to the log. always. π«Ά
π BUGS π
Table-driven rewriting rules make it hard to express if then else and other logical relationships. like yeah she's gorgeous but she cannot do conditional logic, she's a tables girlie, we don't judge. π
βοΈ CONFIGURATION PARAMETERS βοΈ
Changes to main.cf are picked up automatically, as cleanup(8) processes run for only a limited amount of time. Use the command postfix reload to speed up a change.
The text below provides only a parameter summary. See postconf(5) for more details including examples.
π COMPATIBILITY CONTROLS π
undisclosed_recipients_headerβ (seepostconf -doutput) Message header that the Postfixcleanup(8)server inserts when a message contains noTo:orCc:message header.
Available in Postfix version 2.1 only:
enable_errors_toβ default:no. Report mail delivery errors to the address specified with the non-standardErrors-To:message header, instead of the envelope sender address (this feature is removed with Postfix version 2.2, is turned off by default with Postfix version 2.1, and is always turned on with older Postfix versions).
Available in Postfix version 2.6 and later:
always_add_missing_headersβ default:no. Always add(Resent-) From:,To:,Date:orMessage-ID:headers when not present.
Available in Postfix version 2.9 and later:
enable_long_queue_idsβ default:no. Enable long, non-repeating, queue IDs (queue file names).
π¨ HEADER FORMATTING CONTROLS π¨
Available in Postfix version 3.0 and later:
message_drop_headersβ default:bcc, content-length, resent-bcc, return-path. Names of message headers that thecleanup(8)daemon will remove after applyingheader_checks(5)and before invoking Milter applications.
Available in Postfix version 3.3 and later:
header_from_formatβ default:standard. The format of the Postfix-generatedFrom:header.
Available in Postfix version 3.10 and later:
full_name_encoding_charsetβ default:utf-8. The character set name (also called "charset") that Postfix will output when it automatically generates an RFC 2047 encoded full name.non_empty_end_of_header_actionβ default:fix_quietly. How thecleanup(8)daemon will process a message when the primary message header is terminated with a non-empty line.
π§Ό BUILT-IN CONTENT FILTERING CONTROLS π§Ό
Postfix built-in content filtering is meant to stop a flood of worms or viruses. It is not a general content filter. read that again bestie β she is a specific-purpose queen, not a whole content-filtering suite. do not ask her to be something she is not. π
body_checksβ default:empty. Optional lookup tables for content inspection as specified in thebody_checks(5)manual page.header_checksβ default:empty. Optional lookup tables for content inspection of primary non-MIME message headers, as specified in theheader_checks(5)manual page.
Available in Postfix version 2.0 and later:
body_checks_size_limitβ default:51200. How much text in a message body segment (or attachment, if you prefer to use that term) is subjected tobody_checksinspection.mime_header_checksβ default:$header_checks. Optional lookup tables for content inspection of MIME related message headers, as described in theheader_checks(5)manual page.nested_header_checksβ default:$header_checks. Optional lookup tables for content inspection of non-MIME message headers in attached messages, as described in theheader_checks(5)manual page.
Available in Postfix version 2.3 and later:
message_reject_charactersβ default:empty. The set of characters that Postfix will reject in message content.message_strip_charactersβ default:empty. The set of characters that Postfix will remove from message content.
Available in Postfix version 3.9, 3.8.5, 3.7.10, 3.6.14, 3.5.24, and later:
cleanup_replace_stray_cr_lfβ default:yes. Replace each stray<CR>or<LF>character in message content with a space character, to prevent outbound SMTP smuggling, and to make the evaluation of Postfix-added DKIM or other signatures independent from how a remote mail server handles such characters.
π₯ BEFORE QUEUE MILTER CONTROLS π₯
As of version 2.3, Postfix supports the Sendmail version 8 Milter (mail filter) protocol. When mail is not received via the smtpd(8) server, the cleanup(8) server will simulate SMTP events to the extent that this is possible. For details see the MILTER_README document.
non_smtpd_miltersβ default:empty. A list of Milter (mail filter) applications for new mail that does not arrive via the Postfixsmtpd(8)server.milter_protocolβ default:6. The mail filter protocol version and optional protocol extensions for communication with a Milter application; prior to Postfix 2.6 the default protocol is2.milter_default_actionβ default:Postfix >= 3.11: shutdown; Postfix < 3.11: tempfail. The default action when a Milter (mail filter) response is unavailable (for example, bad Postfix configuration or Milter failure).milter_macro_daemon_nameβ default:$myhostname. The{daemon_name}macro value for Milter (mail filter) applications.milter_macro_vβ default:$mail_name $mail_version. The{v}macro value for Milter (mail filter) applications.milter_connect_timeoutβ default:30s. The time limit for connecting to a Milter (mail filter) application, and for negotiating protocol options.milter_command_timeoutβ default:30s. The time limit for sending an SMTP command to a Milter (mail filter) application, and for receiving the response.milter_content_timeoutβ default:300s. The time limit for sending message content to a Milter (mail filter) application, and for receiving the response.milter_connect_macrosβ (seepostconf -doutput) The macros that are sent to Milter (mail filter) applications after completion of an SMTP connection.milter_helo_macrosβ (seepostconf -doutput) The macros that are sent to Milter (mail filter) applications after the SMTPHELOorEHLOcommand.milter_mail_macrosβ (seepostconf -doutput) The macros that are sent to Milter (mail filter) applications after the SMTPMAIL FROMcommand.milter_rcpt_macrosβ (seepostconf -doutput) The macros that are sent to Milter (mail filter) applications after the SMTPRCPT TOcommand.milter_data_macrosβ (seepostconf -doutput) The macros that are sent to version 4 or higher Milter (mail filter) applications after the SMTPDATAcommand.milter_unknown_command_macrosβ (seepostconf -doutput) The macros that are sent to version 3 or higher Milter (mail filter) applications after an unknown SMTP command.milter_end_of_data_macrosβ (seepostconf -doutput) The macros that are sent to Milter (mail filter) applications after the message end-of-data.
Available in Postfix version 2.5 and later:
milter_end_of_header_macrosβ (seepostconf -doutput) The macros that are sent to Milter (mail filter) applications after the end of the message header.
Available in Postfix version 2.7 and later:
milter_header_checksβ default:empty. Optional lookup tables for content inspection of message headers that are produced by Milter applications.
Available in Postfix version 3.1 and later:
milter_macro_defaultsβ default:empty. Optional list of name=value pairs that specify default values for arbitrary macros that Postfix may send to Milter applications.
okay that's the setup bestie, and there's still more coming β don't go anywhere π
π MIME PROCESSING CONTROLS π
okay bestie, MIME is literally the whole vibe of email bodies and attachments, and these knobs decide how hard cleanup(8) goes on it. β¨
β¨ Available in Postfix version 2.0 and later β¨
disable_mime_input_processing(no) β Turn off MIME processing while receiving mail.mime_boundary_length_limit(2048) β The maximal length of MIME multipart boundary strings.mime_nesting_limit(100) β The maximal recursion level that the MIME processor will handle.strict_8bitmime(no) β Enable bothstrict_7bit_headersandstrict_8bitmime_body.strict_7bit_headers(no) β Reject mail with 8-bit text in message headers.strict_8bitmime_body(no) β Reject 8-bit message body text without 8-bit MIME content encoding information.strict_mime_encoding_domain(no) β Reject mail with invalidContent-Transfer-Encoding:information for themessage/*ormultipart/*MIME content types.
β¨ Available in Postfix version 2.5 and later β¨
detect_8bit_encoding_header(yes) β Automatically detect 8BITMIME body content by looking atContent-Transfer-Encoding:message headers; historically, this behavior was hard-coded to be "always on".
π AUTOMATIC BCC RECIPIENT CONTROLS π
Postfix can slide a BCC (blind carbon copy) in automatically when mail enters the mail system, and these are the controls for that. π
always_bcc(empty) β Optional address that receives a "blind carbon copy" of each message that is received by the Postfix mail system.
β¨ Available in Postfix version 2.1 and later β¨
sender_bcc_maps(empty) β Optional BCC (blind carbon-copy) address lookup tables, indexed by envelope sender address.recipient_bcc_maps(empty) β Optional BCC (blind carbon-copy) address lookup tables, indexed by envelope recipient address.
π¦ ADDRESS TRANSFORMATION CONTROLS π¦
Address rewriting gets outsourced to the trivial-rewrite(8) daemon, and the cleanup(8) server is the one doing table-driven address mapping. periodt.
empty_address_recipient(MAILER-DAEMON) β The recipient of mail addressed to the null address.canonical_maps(empty) β Optional address mapping lookup tables for message headers and envelopes.recipient_canonical_maps(empty) β Optional address mapping lookup tables for envelope and header recipient addresses.sender_canonical_maps(empty) β Optional address mapping lookup tables for envelope and header sender addresses.masquerade_classes(envelope_sender, header_sender, header_recipient) β What addresses are subject to address masquerading.masquerade_domains(empty) β Optional list of domains whose subdomain structure will be stripped off in email addresses.masquerade_exceptions(empty) β Optional list of user names that are not subjected to address masquerading, even when their addresses match$masquerade_domains.propagate_unmatched_extensions(canonical, virtual) β What address lookup tables copy an address extension from the lookup key to the lookup result.
π°οΈ Available before Postfix version 2.0 π°οΈ
virtual_maps(empty) β Optional lookup tables with a) names of domains for which all addresses are aliased to addresses in other local or remote domains, and b) addresses that are aliased to addresses in other local or remote domains.
β¨ Available in Postfix version 2.0 and later β¨
virtual_alias_maps($virtual_maps) β Optional lookup tables that are often searched with a full email address (including domain) and that apply to all recipients:local(8), virtual, and remote; this is unlikealias_mapsthat are only searched with an email address localpart (no domain) and that apply only tolocal(8)recipients.
πΈ Available in Postfix version 2.2 and later πΈ
canonical_classes(envelope_sender, envelope_recipient, header_sender, header_recipient) β What addresses are subject tocanonical_mapsaddress mapping.recipient_canonical_classes(envelope_recipient, header_recipient) β What addresses are subject torecipient_canonical_mapsaddress mapping.sender_canonical_classes(envelope_sender, header_sender) β What addresses are subject tosender_canonical_mapsaddress mapping.remote_header_rewrite_domain(empty) β Rewrite or add message headers in mail from remote clients if theremote_header_rewrite_domainparameter value is non-empty, updating incomplete addresses with the domain specified in theremote_header_rewrite_domainparameter, and adding missing headers.
π₯ RESOURCE AND RATE CONTROLS π₯
These are the limits, bestie. The vibes are boundaries, and the boundaries are slay. π
duplicate_filter_limit(1000) β The maximal number of addresses remembered by the address duplicate filter foraliases(5)orvirtual(5)alias expansion, or forshowq(8)queue displays.header_size_limit(102400) β The maximal amount of memory in bytes for storing a message header.hopcount_limit(50) β The maximal number ofReceived:message headers that is allowed in the primary message headers.in_flow_delay(1s) β Time to pause before accepting a new message, when the message arrival rate exceeds the message delivery rate.message_size_limit(10240000) β The maximal size in bytes of a message, including envelope information.
β¨ Available in Postfix version 2.0 and later β¨
header_address_token_limit(10240) β The maximal number of address tokens are allowed in an address message header.mime_boundary_length_limit(2048) β The maximal length of MIME multipart boundary strings.mime_nesting_limit(100) β The maximal recursion level that the MIME processor will handle.queue_file_attribute_count_limit(100) β The maximal number of(name=value)attributes that may be stored in a Postfix queue file.
π Available in Postfix version 2.1 and later π
virtual_alias_expansion_limit(1000) β The maximal number of addresses that virtual alias expansion produces from each original recipient.virtual_alias_recursion_limit(1000) β The maximal nesting depth of virtual alias expansion.
β Available in Postfix version 3.0 and later β
virtual_alias_address_length_limit(1000) β The maximal length of an email address after virtual alias expansion.
π SMTPUTF8 CONTROLS π
Preliminary SMTPUTF8 support rolled in with Postfix 3.0, bestie. π«Ά
smtputf8_enable(yes) β Enable preliminary SMTPUTF8 support for the protocols described in RFC 6531, RFC 6532, and RFC 6533.smtputf8_autodetect_classes(sendmail, verify) β Detect that a message requires SMTPUTF8 support for the specified mail origin classes.
β¨ Available in Postfix version 3.2 and later β¨
enable_idna2003_compatibility(no) β Enable 'transitional' compatibility between IDNA2003 and IDNA2008, when converting UTF-8 domain names to/from the ASCII form that is used for DNS lookups.
π TLS SUPPORT π
β¨ Available in Postfix version 3.10 and later β¨
tls_required_enable(yes) β Enable support for the "TLS-Required: no" message header, defined in RFC 8689.requiretls_esmtp_header(yes) β Record the ESMTP REQUIRETLS request in a "Require-TLS-ESMTP: yes" message header.
π MISCELLANEOUS CONTROLS π
okay so these are the extra little icons in the cleanup(8) control panel, and yes, every single one matters. no cap. π§
config_directory(see 'postconf -d' output) β The default location of the Postfixmain.cfandmaster.cfconfiguration files.daemon_timeout(18000s) β How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer.delay_logging_resolution_limit(2) β The maximal number of digits after the decimal point when logging delay values.delay_warning_time(0h) β The time after which the sender receives a copy of the message headers of mail that is still queued.ipc_timeout(3600s) β The time limit for sending or receiving information over an internal communication channel.max_idle(100s) β The maximum amount of time that an idle Postfix daemon process waits for an incoming connection before terminating voluntarily.max_use(100) β The maximal number of incoming connections that a Postfix daemon process will service before terminating voluntarily.myhostname(see 'postconf -d' output) β The internet hostname of this mail system.myorigin($myhostname) β The domain name that locally-posted mail appears to come from, and that locally posted mail is delivered to.process_id(read-only) β The process ID of a Postfix command or daemon process.process_name(read-only) β The process name of a Postfix command or daemon process.queue_directory(see 'postconf -d' output) β The location of the Postfix top-level queue directory.soft_bounce(no) β Safety net to keep mail queued that would otherwise be returned to the sender.syslog_facility(mail) β The syslog facility of Postfix logging.syslog_name(see 'postconf -d' output) β A prefix that is prepended to the process name in syslog records, so that, for example, "smtpd" becomes "prefix/smtpd".
β¨ Available in Postfix version 2.1 and later β¨
enable_original_recipient(yes) β Enable support for the original recipient address after an address is rewritten to a different address (for example with aliasing or with canonical mapping).
β¨ Available in Postfix 3.3 and later β¨
service_name(read-only) β Themaster.cfservice name of a Postfix daemon process.
β¨ Available in Postfix 3.5 and later β¨
info_log_address_format(external) β The email address form that will be used in non-debug logging (info, warning, etc.).
β¨ Available in Postfix 3.9 and later β¨
force_mime_input_conversion(no) β Convert body content that claims to be 8-bit into quoted-printable, beforeheader_checks,body_checks, Milters, and before after-queue content filters.
πΈ FILES πΈ
/etc/postfix/canonical*, canonical mapping table/etc/postfix/virtual*, virtual mapping table
π« SEE ALSO π«
trivial-rewrite(8), address rewritingqmgr(8), queue managerheader_checks(5), message header content inspectionbody_checks(5), body parts content inspectioncanonical(5), canonical address lookup table formatvirtual(5), virtual alias lookup table formatpostconf(5), configuration parametersmaster(5), generic daemon optionsmaster(8), process managerpostlogd(8), Postfix loggingsyslogd(8), system logging
β¨ README FILES β¨
Okay bestie, when you wanna actually find the readme files and the html docs, the move is to ask Postfix where it put them. Run postconf readme_directory or postconf html_directory and it'll tell you the directory, iykyk π
ADDRESS_REWRITING_READMEβ literally all about Postfix address manipulation, the way it rewrites and massages addresses πCONTENT_INSPECTION_READMEβ everything you need on content inspection π
π LICENSE π
The Secure Mailer license must be distributed with this software. No cap, that's the whole thing. Ship the license with it, periodt. π«Ά
π AUTHOR(S) π
Wietse Venema is the main character of this whole page, and here's where he lives on paper:
Wietse Venema
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA
Also:
Wietse Venema
Google, Inc.
111 8th Avenue
New York, NY 10011, USA
Also (yes, him again, iconic behavior):
Wietse Venema
porcupine.org
He really said "I contain multitudes" and meant it fr fr π
And that's a wrap on this whole page, bestie! π This was CLEANUP(8), straight out of the Postfix manual β go forth and clean up those messages, slay responsibly, and remember: the vibe changes, the facts never do. ππ
π¦
π¦ where this page comes from
- alpine 3.24: postfix-doc 3.11.7-r0 Β· IPL-1.0 EPL-2.0
- arch rolling: postfix 3.11.7-1 Β· EPL-2.0 OR IPL-1.0 AND BSD-4-Clause-UC
- nixos 26.05: postfix 3.11.7
- nixpkgs unstable: postfix 3.11.7
- ubuntu stonking: postfix 3.11.7-1ubuntu2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms