7 /* Postfix SMTP+LMTP client
9 /* \fBsmtp\fR [generic Postfix daemon options]
11 /* The Postfix SMTP+LMTP client implements the SMTP and LMTP mail
12 /* delivery protocols. It processes message delivery requests from
13 /* the queue manager. Each request specifies a queue file, a sender
14 /* address, a domain or host to deliver to, and recipient information.
15 /* This program expects to be run from the \fBmaster\fR(8) process
18 /* The SMTP+LMTP client updates the queue file and marks recipients
19 /* as finished, or it informs the queue manager that delivery should
20 /* be tried again at a later time. Delivery status reports are sent
21 /* to the \fBbounce\fR(8), \fBdefer\fR(8) or \fBtrace\fR(8) daemon as
24 /* The SMTP+LMTP client looks up a list of mail exchanger addresses for
25 /* the destination host, sorts the list by preference, and connects
26 /* to each listed address until it finds a server that responds.
28 /* When a server is not reachable, or when mail delivery fails due
29 /* to a recoverable error condition, the SMTP+LMTP client will try to
30 /* deliver the mail to an alternate host.
32 /* After a successful mail transaction, a connection may be saved
33 /* to the \fBscache\fR(8) connection cache server, so that it
34 /* may be used by any SMTP+LMTP client for a subsequent transaction.
36 /* By default, connection caching is enabled temporarily for
37 /* destinations that have a high volume of mail in the active
38 /* queue. Connection caching can be enabled permanently for
39 /* specific destinations.
40 /* SMTP DESTINATION SYNTAX
43 /* SMTP destinations have the following form:
44 /* .IP \fIdomainname\fR
45 /* .IP \fIdomainname\fR:\fIport\fR
46 /* Look up the mail exchangers for the specified domain, and
47 /* connect to the specified port (default: \fBsmtp\fR).
48 /* .IP [\fIhostname\fR]
49 /* .IP [\fIhostname\fR]:\fIport\fR
50 /* Look up the address(es) of the specified host, and connect to
51 /* the specified port (default: \fBsmtp\fR).
52 /* .IP [\fIaddress\fR]
53 /* .IP [\fIaddress\fR]:\fIport\fR
54 /* Connect to the host at the specified address, and connect
55 /* to the specified port (default: \fBsmtp\fR). An IPv6 address
56 /* must be formatted as [\fBipv6\fR:\fIaddress\fR].
57 /* LMTP DESTINATION SYNTAX
60 /* LMTP destinations have the following form:
61 /* .IP \fBunix\fR:\fIpathname\fR
62 /* Connect to the local UNIX-domain server that is bound to the specified
63 /* \fIpathname\fR. If the process runs chrooted, an absolute pathname
64 /* is interpreted relative to the Postfix queue directory.
65 /* .IP \fBinet\fR:\fIhostname\fR
66 /* .IP \fBinet\fB:\fIhostname\fR:\fIport\fR
67 /* .IP \fBinet\fR:[\fIaddress\fR]
68 /* .IP \fBinet\fR:[\fIaddress\fR]:\fIport\fR
69 /* Connect to the specified TCP port on the specified local or
70 /* remote host. If no port is specified, connect to the port defined as
71 /* \fBlmtp\fR in \fBservices\fR(4).
72 /* If no such service is found, the \fBlmtp_tcp_port\fR configuration
73 /* parameter (default value of 24) will be used.
74 /* An IPv6 address must be formatted as [\fBipv6\fR:\fIaddress\fR].
79 /* The SMTP+LMTP client is moderately security-sensitive. It
80 /* talks to SMTP or LMTP servers and to DNS servers on the
81 /* network. The SMTP+LMTP client can be run chrooted at fixed
84 /* RFC 821 (SMTP protocol)
85 /* RFC 822 (ARPA Internet Text Messages)
86 /* RFC 1651 (SMTP service extensions)
87 /* RFC 1652 (8bit-MIME transport)
88 /* RFC 1870 (Message Size Declaration)
89 /* RFC 2033 (LMTP protocol)
90 /* RFC 2034 (SMTP Enhanced Error Codes)
91 /* RFC 2045 (MIME: Format of Internet Message Bodies)
92 /* RFC 2046 (MIME: Media Types)
93 /* RFC 2554 (AUTH command)
94 /* RFC 2821 (SMTP protocol)
95 /* RFC 2920 (SMTP Pipelining)
96 /* RFC 3207 (STARTTLS command)
97 /* RFC 3461 (SMTP DSN Extension)
98 /* RFC 3463 (Enhanced Status Codes)
99 /* RFC 4954 (AUTH command)
101 /* Problems and transactions are logged to \fBsyslogd\fR(8).
102 /* Corrupted message files are marked so that the queue manager can
103 /* move them to the \fBcorrupt\fR queue for further inspection.
105 /* Depending on the setting of the \fBnotify_classes\fR parameter,
106 /* the postmaster is notified of bounces, protocol problems, and of
109 /* SMTP and LMTP connection caching does not work with TLS. The necessary
110 /* support for TLS object passivation and re-activation does not
111 /* exist without closing the session, which defeats the purpose.
113 /* SMTP and LMTP connection caching assumes that SASL credentials
114 /* are valid for all destinations that map onto the same IP
115 /* address and TCP port.
116 /* CONFIGURATION PARAMETERS
119 /* Before Postfix version 2.3, the LMTP client is a separate
120 /* program that implements only a subset of the functionality
121 /* available with SMTP: there is no support for TLS, and
122 /* connections are cached in-process, making it ineffective
123 /* when the client is used for multiple domains.
125 /* Most smtp_\fIxxx\fR configuration parameters have an
126 /* lmtp_\fIxxx\fR "mirror" parameter for the equivalent LMTP
127 /* feature. This document describes only those LMTP-related
128 /* parameters that aren't simply "mirror" parameters.
130 /* Changes to \fBmain.cf\fR are picked up automatically, as \fBsmtp\fR(8)
131 /* processes run for only a limited amount of time. Use the command
132 /* "\fBpostfix reload\fR" to speed up a change.
134 /* The text below provides only a parameter summary. See
135 /* \fBpostconf\fR(5) for more details including examples.
136 /* COMPATIBILITY CONTROLS
139 /* .IP "\fBignore_mx_lookup_error (no)\fR"
140 /* Ignore DNS MX lookups that produce no response.
141 /* .IP "\fBsmtp_always_send_ehlo (yes)\fR"
142 /* Always send EHLO at the start of an SMTP session.
143 /* .IP "\fBsmtp_never_send_ehlo (no)\fR"
144 /* Never send EHLO at the start of an SMTP session.
145 /* .IP "\fBsmtp_defer_if_no_mx_address_found (no)\fR"
146 /* Defer mail delivery when no MX record resolves to an IP address.
147 /* .IP "\fBsmtp_line_length_limit (990)\fR"
148 /* The maximal length of message header and body lines that Postfix
149 /* will send via SMTP.
150 /* .IP "\fBsmtp_pix_workaround_delay_time (10s)\fR"
151 /* How long the Postfix SMTP client pauses before sending
152 /* ".<CR><LF>" in order to work around the PIX firewall
153 /* "<CR><LF>.<CR><LF>" bug.
154 /* .IP "\fBsmtp_pix_workaround_threshold_time (500s)\fR"
155 /* How long a message must be queued before the Postfix SMTP client
156 /* turns on the PIX firewall "<CR><LF>.<CR><LF>"
157 /* bug workaround for delivery through firewalls with "smtp fixup"
159 /* .IP "\fBsmtp_pix_workarounds (disable_esmtp, delay_dotcrlf)\fR"
160 /* A list that specifies zero or more workarounds for CISCO PIX
162 /* .IP "\fBsmtp_pix_workaround_maps (empty)\fR"
163 /* Lookup tables, indexed by the remote SMTP server address, with
164 /* per-destination workarounds for CISCO PIX firewall bugs.
165 /* .IP "\fBsmtp_quote_rfc821_envelope (yes)\fR"
166 /* Quote addresses in SMTP MAIL FROM and RCPT TO commands as required
168 /* .IP "\fBsmtp_skip_5xx_greeting (yes)\fR"
169 /* Skip SMTP servers that greet with a 5XX status code (go away, do
170 /* not try again later).
171 /* .IP "\fBsmtp_skip_quit_response (yes)\fR"
172 /* Do not wait for the response to the SMTP QUIT command.
174 /* Available in Postfix version 2.0 and earlier:
175 /* .IP "\fBsmtp_skip_4xx_greeting (yes)\fR"
176 /* Skip SMTP servers that greet with a 4XX status code (go away, try
179 /* Available in Postfix version 2.2 and later:
180 /* .IP "\fBsmtp_discard_ehlo_keyword_address_maps (empty)\fR"
181 /* Lookup tables, indexed by the remote SMTP server address, with
182 /* case insensitive lists of EHLO keywords (pipelining, starttls, auth,
183 /* etc.) that the Postfix SMTP client will ignore in the EHLO response from a
184 /* remote SMTP server.
185 /* .IP "\fBsmtp_discard_ehlo_keywords (empty)\fR"
186 /* A case insensitive list of EHLO keywords (pipelining, starttls,
187 /* auth, etc.) that the Postfix SMTP client will ignore in the EHLO
188 /* response from a remote SMTP server.
189 /* .IP "\fBsmtp_generic_maps (empty)\fR"
190 /* Optional lookup tables that perform address rewriting in the
191 /* SMTP client, typically to transform a locally valid address into
192 /* a globally valid address when sending mail across the Internet.
194 /* Available in Postfix version 2.2.9 and later:
195 /* .IP "\fBsmtp_cname_overrides_servername (version dependent)\fR"
196 /* Allow DNS CNAME records to override the servername that the
197 /* Postfix SMTP client uses for logging, SASL password lookup, TLS
198 /* policy decisions, or TLS certificate verification.
200 /* Available in Postfix version 2.3 and later:
201 /* .IP "\fBlmtp_discard_lhlo_keyword_address_maps (empty)\fR"
202 /* Lookup tables, indexed by the remote LMTP server address, with
203 /* case insensitive lists of LHLO keywords (pipelining, starttls,
204 /* auth, etc.) that the LMTP client will ignore in the LHLO response
205 /* from a remote LMTP server.
206 /* .IP "\fBlmtp_discard_lhlo_keywords (empty)\fR"
207 /* A case insensitive list of LHLO keywords (pipelining, starttls,
208 /* auth, etc.) that the LMTP client will ignore in the LHLO response
209 /* from a remote LMTP server.
211 /* Available in Postfix version 2.4.4 and later:
212 /* .IP "\fBsend_cyrus_sasl_authzid (no)\fR"
213 /* When authenticating to a remote SMTP or LMTP server with the
214 /* default setting "no", send no SASL authoriZation ID (authzid); send
215 /* only the SASL authentiCation ID (authcid) plus the authcid's password.
217 /* Available in Postfix version 2.5 and later:
218 /* .IP "\fBsmtp_header_checks (empty)\fR"
219 /* Restricted \fBheader_checks\fR(5) tables for the Postfix SMTP client.
220 /* .IP "\fBsmtp_mime_header_checks (empty)\fR"
221 /* Restricted \fBmime_header_checks\fR(5) tables for the Postfix SMTP
223 /* .IP "\fBsmtp_nested_header_checks (empty)\fR"
224 /* Restricted \fBnested_header_checks\fR(5) tables for the Postfix SMTP
226 /* .IP "\fBsmtp_body_checks (empty)\fR"
227 /* Restricted \fBbody_checks\fR(5) tables for the Postfix SMTP client.
229 /* Available in Postfix version 2.6 and later:
230 /* .IP "\fBtcp_windowsize (0)\fR"
231 /* An optional workaround for routers that break TCP window scaling.
232 /* MIME PROCESSING CONTROLS
235 /* Available in Postfix version 2.0 and later:
236 /* .IP "\fBdisable_mime_output_conversion (no)\fR"
237 /* Disable the conversion of 8BITMIME format to 7BIT format.
238 /* .IP "\fBmime_boundary_length_limit (2048)\fR"
239 /* The maximal length of MIME multipart boundary strings.
240 /* .IP "\fBmime_nesting_limit (100)\fR"
241 /* The maximal recursion level that the MIME processor will handle.
242 /* EXTERNAL CONTENT INSPECTION CONTROLS
245 /* Available in Postfix version 2.1 and later:
246 /* .IP "\fBsmtp_send_xforward_command (no)\fR"
247 /* Send the non-standard XFORWARD command when the Postfix SMTP server
248 /* EHLO response announces XFORWARD support.
249 /* SASL AUTHENTICATION CONTROLS
252 /* .IP "\fBsmtp_sasl_auth_enable (no)\fR"
253 /* Enable SASL authentication in the Postfix SMTP client.
254 /* .IP "\fBsmtp_sasl_password_maps (empty)\fR"
255 /* Optional SMTP client lookup tables with one username:password entry
256 /* per remote hostname or domain, or sender address when sender-dependent
257 /* authentication is enabled.
258 /* .IP "\fBsmtp_sasl_security_options (noplaintext, noanonymous)\fR"
259 /* Postfix SMTP client SASL security options; as of Postfix 2.3
260 /* the list of available
261 /* features depends on the SASL client implementation that is selected
262 /* with \fBsmtp_sasl_type\fR.
264 /* Available in Postfix version 2.2 and later:
265 /* .IP "\fBsmtp_sasl_mechanism_filter (empty)\fR"
266 /* If non-empty, a Postfix SMTP client filter for the remote SMTP
267 /* server's list of offered SASL mechanisms.
269 /* Available in Postfix version 2.3 and later:
270 /* .IP "\fBsmtp_sender_dependent_authentication (no)\fR"
271 /* Enable sender-dependent authentication in the Postfix SMTP client; this is
272 /* available only with SASL authentication, and disables SMTP connection
273 /* caching to ensure that mail from different senders will use the
274 /* appropriate credentials.
275 /* .IP "\fBsmtp_sasl_path (empty)\fR"
276 /* Implementation-specific information that the Postfix SMTP client
278 /* the SASL plug-in implementation that is selected with
279 /* \fBsmtp_sasl_type\fR.
280 /* .IP "\fBsmtp_sasl_type (cyrus)\fR"
281 /* The SASL plug-in type that the Postfix SMTP client should use
282 /* for authentication.
284 /* Available in Postfix version 2.5 and later:
285 /* .IP "\fBsmtp_sasl_auth_cache_name (empty)\fR"
286 /* An optional table to prevent repeated SASL authentication
287 /* failures with the same remote SMTP server hostname, username and
289 /* .IP "\fBsmtp_sasl_auth_cache_time (90d)\fR"
290 /* The maximal age of an smtp_sasl_auth_cache_name entry before it
292 /* .IP "\fBsmtp_sasl_auth_soft_bounce (yes)\fR"
293 /* When a remote SMTP server rejects a SASL authentication request
294 /* with a 535 reply code, defer mail delivery instead of returning
295 /* mail as undeliverable.
296 /* STARTTLS SUPPORT CONTROLS
299 /* Detailed information about STARTTLS configuration may be found
300 /* in the TLS_README document.
301 /* .IP "\fBsmtp_tls_security_level (empty)\fR"
302 /* The default SMTP TLS security level for the Postfix SMTP client;
303 /* when a non-empty value is specified, this overrides the obsolete
304 /* parameters smtp_use_tls, smtp_enforce_tls, and smtp_tls_enforce_peername.
305 /* .IP "\fBsmtp_sasl_tls_security_options ($smtp_sasl_security_options)\fR"
306 /* The SASL authentication security options that the Postfix SMTP
307 /* client uses for TLS encrypted SMTP sessions.
308 /* .IP "\fBsmtp_starttls_timeout (300s)\fR"
309 /* Time limit for Postfix SMTP client write and read operations
310 /* during TLS startup and shutdown handshake procedures.
311 /* .IP "\fBsmtp_tls_CAfile (empty)\fR"
312 /* A file containing CA certificates of root CAs trusted to sign
313 /* either remote SMTP server certificates or intermediate CA certificates.
314 /* .IP "\fBsmtp_tls_CApath (empty)\fR"
315 /* Directory with PEM format certificate authority certificates
316 /* that the Postfix SMTP client uses to verify a remote SMTP server
318 /* .IP "\fBsmtp_tls_cert_file (empty)\fR"
319 /* File with the Postfix SMTP client RSA certificate in PEM format.
320 /* .IP "\fBsmtp_tls_mandatory_ciphers (medium)\fR"
321 /* The minimum TLS cipher grade that the Postfix SMTP client will
323 /* mandatory TLS encryption.
324 /* .IP "\fBsmtp_tls_exclude_ciphers (empty)\fR"
325 /* List of ciphers or cipher types to exclude from the Postfix
326 /* SMTP client cipher
327 /* list at all TLS security levels.
328 /* .IP "\fBsmtp_tls_mandatory_exclude_ciphers (empty)\fR"
329 /* Additional list of ciphers or cipher types to exclude from the
330 /* SMTP client cipher list at mandatory TLS security levels.
331 /* .IP "\fBsmtp_tls_dcert_file (empty)\fR"
332 /* File with the Postfix SMTP client DSA certificate in PEM format.
333 /* .IP "\fBsmtp_tls_dkey_file ($smtp_tls_dcert_file)\fR"
334 /* File with the Postfix SMTP client DSA private key in PEM format.
335 /* .IP "\fBsmtp_tls_key_file ($smtp_tls_cert_file)\fR"
336 /* File with the Postfix SMTP client RSA private key in PEM format.
337 /* .IP "\fBsmtp_tls_loglevel (0)\fR"
338 /* Enable additional Postfix SMTP client logging of TLS activity.
339 /* .IP "\fBsmtp_tls_note_starttls_offer (no)\fR"
340 /* Log the hostname of a remote SMTP server that offers STARTTLS,
341 /* when TLS is not already enabled for that server.
342 /* .IP "\fBsmtp_tls_policy_maps (empty)\fR"
343 /* Optional lookup tables with the Postfix SMTP client TLS security
344 /* policy by next-hop destination; when a non-empty value is specified,
345 /* this overrides the obsolete smtp_tls_per_site parameter.
346 /* .IP "\fBsmtp_tls_mandatory_protocols (SSLv3, TLSv1)\fR"
347 /* List of SSL/TLS protocols that the Postfix SMTP client will use with
348 /* mandatory TLS encryption.
349 /* .IP "\fBsmtp_tls_scert_verifydepth (9)\fR"
350 /* The verification depth for remote SMTP server certificates.
351 /* .IP "\fBsmtp_tls_secure_cert_match (nexthop, dot-nexthop)\fR"
352 /* The server certificate peername verification method for the
353 /* "secure" TLS security level.
354 /* .IP "\fBsmtp_tls_session_cache_database (empty)\fR"
355 /* Name of the file containing the optional Postfix SMTP client
356 /* TLS session cache.
357 /* .IP "\fBsmtp_tls_session_cache_timeout (3600s)\fR"
358 /* The expiration time of Postfix SMTP client TLS session cache
360 /* .IP "\fBsmtp_tls_verify_cert_match (hostname)\fR"
361 /* The server certificate peername verification method for the
362 /* "verify" TLS security level.
363 /* .IP "\fBtls_daemon_random_bytes (32)\fR"
364 /* The number of pseudo-random bytes that an \fBsmtp\fR(8) or \fBsmtpd\fR(8)
365 /* process requests from the \fBtlsmgr\fR(8) server in order to seed its
366 /* internal pseudo random number generator (PRNG).
367 /* .IP "\fBtls_high_cipherlist (ALL:!EXPORT:!LOW:!MEDIUM:+RC4:@STRENGTH)\fR"
368 /* The OpenSSL cipherlist for "HIGH" grade ciphers.
369 /* .IP "\fBtls_medium_cipherlist (ALL:!EXPORT:!LOW:+RC4:@STRENGTH)\fR"
370 /* The OpenSSL cipherlist for "MEDIUM" or higher grade ciphers.
371 /* .IP "\fBtls_low_cipherlist (ALL:!EXPORT:+RC4:@STRENGTH)\fR"
372 /* The OpenSSL cipherlist for "LOW" or higher grade ciphers.
373 /* .IP "\fBtls_export_cipherlist (ALL:+RC4:@STRENGTH)\fR"
374 /* The OpenSSL cipherlist for "EXPORT" or higher grade ciphers.
375 /* .IP "\fBtls_null_cipherlist (eNULL:!aNULL)\fR"
376 /* The OpenSSL cipherlist for "NULL" grade ciphers that provide
377 /* authentication without encryption.
379 /* Available in Postfix version 2.4 and later:
380 /* .IP "\fBsmtp_sasl_tls_verified_security_options ($smtp_sasl_tls_security_options)\fR"
381 /* The SASL authentication security options that the Postfix SMTP
382 /* client uses for TLS encrypted SMTP sessions with a verified server
385 /* Available in Postfix version 2.5 and later:
386 /* .IP "\fBsmtp_tls_fingerprint_cert_match (empty)\fR"
387 /* List of acceptable remote SMTP server certificate fingerprints
388 /* for the "fingerprint" TLS security level (\fBsmtp_tls_security_level\fR =
390 /* .IP "\fBsmtp_tls_fingerprint_digest (md5)\fR"
391 /* The message digest algorithm used to construct remote SMTP server
392 /* certificate fingerprints.
394 /* Available in Postfix version 2.6 and later:
395 /* .IP "\fBsmtp_tls_protocols (!SSLv2)\fR"
396 /* List of TLS protocols that the Postfix SMTP client will exclude or
397 /* include with opportunistic TLS encryption.
398 /* .IP "\fBsmtp_tls_ciphers (export)\fR"
399 /* The minimum TLS cipher grade that the Postfix SMTP client
400 /* will use with opportunistic TLS encryption.
401 /* .IP "\fBsmtp_tls_eccert_file (empty)\fR"
402 /* File with the Postfix SMTP client ECDSA certificate in PEM format.
403 /* .IP "\fBsmtp_tls_eckey_file ($smtp_tls_eccert_file)\fR"
404 /* File with the Postfix SMTP client ECDSA private key in PEM format.
405 /* OBSOLETE STARTTLS CONTROLS
408 /* The following configuration parameters exist for compatibility
409 /* with Postfix versions before 2.3. Support for these will
410 /* be removed in a future release.
411 /* .IP "\fBsmtp_use_tls (no)\fR"
412 /* Opportunistic mode: use TLS when a remote SMTP server announces
413 /* STARTTLS support, otherwise send the mail in the clear.
414 /* .IP "\fBsmtp_enforce_tls (no)\fR"
415 /* Enforcement mode: require that remote SMTP servers use TLS
416 /* encryption, and never send mail in the clear.
417 /* .IP "\fBsmtp_tls_enforce_peername (yes)\fR"
418 /* With mandatory TLS encryption, require that the remote SMTP
419 /* server hostname matches the information in the remote SMTP server
421 /* .IP "\fBsmtp_tls_per_site (empty)\fR"
422 /* Optional lookup tables with the Postfix SMTP client TLS usage
423 /* policy by next-hop destination and by remote SMTP server hostname.
424 /* .IP "\fBsmtp_tls_cipherlist (empty)\fR"
425 /* Obsolete Postfix < 2.3 control for the Postfix SMTP client TLS
427 /* RESOURCE AND RATE CONTROLS
430 /* .IP "\fBsmtp_destination_concurrency_limit ($default_destination_concurrency_limit)\fR"
431 /* The maximal number of parallel deliveries to the same destination
432 /* via the smtp message delivery transport.
433 /* .IP "\fBsmtp_destination_recipient_limit ($default_destination_recipient_limit)\fR"
434 /* The maximal number of recipients per message for the smtp
435 /* message delivery transport.
436 /* .IP "\fBsmtp_connect_timeout (30s)\fR"
437 /* The SMTP client time limit for completing a TCP connection, or
438 /* zero (use the operating system built-in time limit).
439 /* .IP "\fBsmtp_helo_timeout (300s)\fR"
440 /* The SMTP client time limit for sending the HELO or EHLO command,
441 /* and for receiving the initial server response.
442 /* .IP "\fBlmtp_lhlo_timeout (300s)\fR"
443 /* The LMTP client time limit for sending the LHLO command, and
444 /* for receiving the initial server response.
445 /* .IP "\fBsmtp_xforward_timeout (300s)\fR"
446 /* The SMTP client time limit for sending the XFORWARD command, and
447 /* for receiving the server response.
448 /* .IP "\fBsmtp_mail_timeout (300s)\fR"
449 /* The SMTP client time limit for sending the MAIL FROM command, and
450 /* for receiving the server response.
451 /* .IP "\fBsmtp_rcpt_timeout (300s)\fR"
452 /* The SMTP client time limit for sending the SMTP RCPT TO command, and
453 /* for receiving the server response.
454 /* .IP "\fBsmtp_data_init_timeout (120s)\fR"
455 /* The SMTP client time limit for sending the SMTP DATA command, and for
456 /* receiving the server response.
457 /* .IP "\fBsmtp_data_xfer_timeout (180s)\fR"
458 /* The SMTP client time limit for sending the SMTP message content.
459 /* .IP "\fBsmtp_data_done_timeout (600s)\fR"
460 /* The SMTP client time limit for sending the SMTP ".", and for receiving
461 /* the server response.
462 /* .IP "\fBsmtp_quit_timeout (300s)\fR"
463 /* The SMTP client time limit for sending the QUIT command, and for
464 /* receiving the server response.
466 /* Available in Postfix version 2.1 and later:
467 /* .IP "\fBsmtp_mx_address_limit (5)\fR"
468 /* The maximal number of MX (mail exchanger) IP addresses that can
469 /* result from mail exchanger lookups, or zero (no limit).
470 /* .IP "\fBsmtp_mx_session_limit (2)\fR"
471 /* The maximal number of SMTP sessions per delivery request before
472 /* giving up or delivering to a fall-back relay host, or zero (no
474 /* .IP "\fBsmtp_rset_timeout (20s)\fR"
475 /* The SMTP client time limit for sending the RSET command, and
476 /* for receiving the server response.
478 /* Available in Postfix version 2.2 and earlier:
479 /* .IP "\fBlmtp_cache_connection (yes)\fR"
480 /* Keep Postfix LMTP client connections open for up to $max_idle
483 /* Available in Postfix version 2.2 and later:
484 /* .IP "\fBsmtp_connection_cache_destinations (empty)\fR"
485 /* Permanently enable SMTP connection caching for the specified
487 /* .IP "\fBsmtp_connection_cache_on_demand (yes)\fR"
488 /* Temporarily enable SMTP connection caching while a destination
489 /* has a high volume of mail in the active queue.
490 /* .IP "\fBsmtp_connection_reuse_time_limit (300s)\fR"
491 /* The amount of time during which Postfix will use an SMTP
492 /* connection repeatedly.
493 /* .IP "\fBsmtp_connection_cache_time_limit (2s)\fR"
494 /* When SMTP connection caching is enabled, the amount of time that
495 /* an unused SMTP client socket is kept open before it is closed.
497 /* Available in Postfix version 2.3 and later:
498 /* .IP "\fBconnection_cache_protocol_timeout (5s)\fR"
499 /* Time limit for connection cache connect, send or receive
501 /* TROUBLE SHOOTING CONTROLS
504 /* .IP "\fBdebug_peer_level (2)\fR"
505 /* The increment in verbose logging level when a remote client or
506 /* server matches a pattern in the debug_peer_list parameter.
507 /* .IP "\fBdebug_peer_list (empty)\fR"
508 /* Optional list of remote client or server hostname or network
509 /* address patterns that cause the verbose logging level to increase
510 /* by the amount specified in $debug_peer_level.
511 /* .IP "\fBerror_notice_recipient (postmaster)\fR"
512 /* The recipient of postmaster notifications about mail delivery
513 /* problems that are caused by policy, resource, software or protocol
515 /* .IP "\fBinternal_mail_filter_classes (empty)\fR"
516 /* What categories of Postfix-generated mail are subject to
517 /* before-queue content inspection by non_smtpd_milters, header_checks
519 /* .IP "\fBnotify_classes (resource, software)\fR"
520 /* The list of error classes that are reported to the postmaster.
521 /* MISCELLANEOUS CONTROLS
524 /* .IP "\fBbest_mx_transport (empty)\fR"
525 /* Where the Postfix SMTP client should deliver mail when it detects
526 /* a "mail loops back to myself" error condition.
527 /* .IP "\fBconfig_directory (see 'postconf -d' output)\fR"
528 /* The default location of the Postfix main.cf and master.cf
529 /* configuration files.
530 /* .IP "\fBdaemon_timeout (18000s)\fR"
531 /* How much time a Postfix daemon process may take to handle a
532 /* request before it is terminated by a built-in watchdog timer.
533 /* .IP "\fBdelay_logging_resolution_limit (2)\fR"
534 /* The maximal number of digits after the decimal point when logging
535 /* sub-second delay values.
536 /* .IP "\fBdisable_dns_lookups (no)\fR"
537 /* Disable DNS lookups in the Postfix SMTP and LMTP clients.
538 /* .IP "\fBinet_interfaces (all)\fR"
539 /* The network interface addresses that this mail system receives
541 /* .IP "\fBinet_protocols (ipv4)\fR"
542 /* The Internet protocols Postfix will attempt to use when making
543 /* or accepting connections.
544 /* .IP "\fBipc_timeout (3600s)\fR"
545 /* The time limit for sending or receiving information over an internal
546 /* communication channel.
547 /* .IP "\fBlmtp_assume_final (no)\fR"
548 /* When an LMTP server announces no DSN support, assume that the
549 /* server performs final delivery, and send "delivered" delivery status
550 /* notifications instead of "relayed".
551 /* .IP "\fBlmtp_tcp_port (24)\fR"
552 /* The default TCP port that the Postfix LMTP client connects to.
553 /* .IP "\fBmax_idle (100s)\fR"
554 /* The maximum amount of time that an idle Postfix daemon process waits
555 /* for an incoming connection before terminating voluntarily.
556 /* .IP "\fBmax_use (100)\fR"
557 /* The maximal number of incoming connections that a Postfix daemon
558 /* process will service before terminating voluntarily.
559 /* .IP "\fBprocess_id (read-only)\fR"
560 /* The process ID of a Postfix command or daemon process.
561 /* .IP "\fBprocess_name (read-only)\fR"
562 /* The process name of a Postfix command or daemon process.
563 /* .IP "\fBproxy_interfaces (empty)\fR"
564 /* The network interface addresses that this mail system receives mail
565 /* on by way of a proxy or network address translation unit.
566 /* .IP "\fBsmtp_bind_address (empty)\fR"
567 /* An optional numerical network address that the Postfix SMTP client
568 /* should bind to when making an IPv4 connection.
569 /* .IP "\fBsmtp_bind_address6 (empty)\fR"
570 /* An optional numerical network address that the Postfix SMTP client
571 /* should bind to when making an IPv6 connection.
572 /* .IP "\fBsmtp_helo_name ($myhostname)\fR"
573 /* The hostname to send in the SMTP EHLO or HELO command.
574 /* .IP "\fBlmtp_lhlo_name ($myhostname)\fR"
575 /* The hostname to send in the LMTP LHLO command.
576 /* .IP "\fBsmtp_host_lookup (dns)\fR"
577 /* What mechanisms when the Postfix SMTP client uses to look up a host's IP
579 /* .IP "\fBsmtp_randomize_addresses (yes)\fR"
580 /* Randomize the order of equal-preference MX host addresses.
581 /* .IP "\fBsyslog_facility (mail)\fR"
582 /* The syslog facility of Postfix logging.
583 /* .IP "\fBsyslog_name (see 'postconf -d' output)\fR"
584 /* The mail system name that is prepended to the process name in syslog
585 /* records, so that "smtpd" becomes, for example, "postfix/smtpd".
587 /* Available with Postfix 2.2 and earlier:
588 /* .IP "\fBfallback_relay (empty)\fR"
589 /* Optional list of relay hosts for SMTP destinations that can't be
590 /* found or that are unreachable.
592 /* Available with Postfix 2.3 and later:
593 /* .IP "\fBsmtp_fallback_relay ($fallback_relay)\fR"
594 /* Optional list of relay hosts for SMTP destinations that can't be
595 /* found or that are unreachable.
597 /* generic(5), output address rewriting
598 /* header_checks(5), message header content inspection
599 /* body_checks(5), body parts content inspection
600 /* qmgr(8), queue manager
601 /* bounce(8), delivery status reports
602 /* scache(8), connection cache server
603 /* postconf(5), configuration parameters
604 /* master(5), generic daemon options
605 /* master(8), process manager
606 /* tlsmgr(8), TLS session and PRNG management
607 /* syslogd(8), system logging
611 /* Use "\fBpostconf readme_directory\fR" or
612 /* "\fBpostconf html_directory\fR" to locate this information.
615 /* SASL_README, Postfix SASL howto
616 /* TLS_README, Postfix STARTTLS howto
620 /* The Secure Mailer license must be distributed with this software.
623 /* IBM T.J. Watson Research
625 /* Yorktown Heights, NY 10598, USA
627 /* Command pipelining in cooperation with:
629 /* Oaktree Internet Solutions Ltd.,
633 /* CV1 4LY, United Kingdom.
635 /* SASL support originally by:
637 /* SuSE Rhein/Main AG
638 /* 65760 Eschborn, Germany
640 /* TLS support originally by:
643 /* Allgemeine Elektrotechnik
644 /* Universitaetsplatz 3-4
645 /* D-03044 Cottbus, Germany
647 /* Revised TLS and SMTP connection cache support by:
652 /* System library. */
654 #include <sys_defs.h>
660 #include <stringops.h>
662 /* Utility library. */
665 #include <mymalloc.h>
666 #include <name_mask.h>
667 #include <name_code.h>
669 /* Global library. */
671 #include <deliver_request.h>
672 #include <mail_params.h>
673 #include <mail_version.h>
674 #include <mail_conf.h>
675 #include <debug_peer.h>
676 #include <flush_clnt.h>
678 #include <string_list.h>
680 #include <ext_prop.h>
682 /* Single server skeleton. */
684 #include <mail_server.h>
686 /* Application-specific. */
689 #include "smtp_sasl.h"
692 * Tunable parameters. These have compiled-in defaults that can be overruled
693 * by settings in the global Postfix configuration file.
695 int var_smtp_conn_tmout
;
696 int var_smtp_helo_tmout
;
697 int var_smtp_xfwd_tmout
;
698 int var_smtp_mail_tmout
;
699 int var_smtp_rcpt_tmout
;
700 int var_smtp_data0_tmout
;
701 int var_smtp_data1_tmout
;
702 int var_smtp_data2_tmout
;
703 int var_smtp_rset_tmout
;
704 int var_smtp_quit_tmout
;
705 char *var_inet_interfaces
;
706 char *var_notify_classes
;
707 int var_smtp_skip_5xx_greeting
;
708 int var_ign_mx_lookup_err
;
709 int var_skip_quit_resp
;
710 char *var_fallback_relay
;
711 char *var_bestmx_transp
;
712 char *var_error_rcpt
;
713 int var_smtp_always_ehlo
;
714 int var_smtp_never_ehlo
;
715 char *var_smtp_sasl_opts
;
716 char *var_smtp_sasl_path
;
717 char *var_smtp_sasl_passwd
;
718 bool var_smtp_sasl_enable
;
719 char *var_smtp_sasl_mechs
;
720 char *var_smtp_sasl_type
;
721 char *var_smtp_bind_addr
;
722 char *var_smtp_bind_addr6
;
723 bool var_smtp_rand_addr
;
724 int var_smtp_pix_thresh
;
725 int var_smtp_pix_delay
;
726 int var_smtp_line_limit
;
727 char *var_smtp_helo_name
;
728 char *var_smtp_host_lookup
;
729 bool var_smtp_quote_821_env
;
730 bool var_smtp_defer_mxaddr
;
731 bool var_smtp_send_xforward
;
732 int var_smtp_mxaddr_limit
;
733 int var_smtp_mxsess_limit
;
734 int var_smtp_cache_conn
;
735 int var_smtp_reuse_time
;
736 char *var_smtp_cache_dest
;
737 char *var_scache_service
;
738 bool var_smtp_cache_demand
;
739 char *var_smtp_ehlo_dis_words
;
740 char *var_smtp_ehlo_dis_maps
;
742 char *var_smtp_tls_level
;
743 bool var_smtp_use_tls
;
744 bool var_smtp_enforce_tls
;
745 char *var_smtp_tls_per_site
;
746 char *var_smtp_tls_policy
;
749 char *var_smtp_sasl_tls_opts
;
750 char *var_smtp_sasl_tlsv_opts
;
751 int var_smtp_starttls_tmout
;
752 char *var_smtp_tls_CAfile
;
753 char *var_smtp_tls_CApath
;
754 char *var_smtp_tls_cert_file
;
755 char *var_smtp_tls_mand_ciph
;
756 char *var_smtp_tls_excl_ciph
;
757 char *var_smtp_tls_mand_excl
;
758 char *var_smtp_tls_dcert_file
;
759 char *var_smtp_tls_dkey_file
;
760 bool var_smtp_tls_enforce_peername
;
761 char *var_smtp_tls_key_file
;
762 int var_smtp_tls_loglevel
;
763 bool var_smtp_tls_note_starttls_offer
;
764 char *var_smtp_tls_mand_proto
;
765 char *var_smtp_tls_sec_cmatch
;
766 int var_smtp_tls_scert_vd
;
767 char *var_smtp_tls_vfy_cmatch
;
768 char *var_smtp_tls_fpt_cmatch
;
769 char *var_smtp_tls_fpt_dgst
;
770 char *var_smtp_tls_proto
;
771 char *var_smtp_tls_ciph
;
772 char *var_smtp_tls_eccert_file
;
773 char *var_smtp_tls_eckey_file
;
777 char *var_smtp_generic_maps
;
778 char *var_prop_extension
;
779 bool var_smtp_sender_auth
;
780 char *var_lmtp_tcp_port
;
781 int var_scache_proto_tmout
;
782 bool var_smtp_cname_overr
;
783 char *var_smtp_pix_bug_words
;
784 char *var_smtp_pix_bug_maps
;
785 char *var_cyrus_conf_path
;
786 char *var_smtp_head_chks
;
787 char *var_smtp_mime_chks
;
788 char *var_smtp_nest_chks
;
789 char *var_smtp_body_chks
;
790 bool var_lmtp_assume_final
;
792 /* Special handling of 535 AUTH errors. */
793 char *var_smtp_sasl_auth_cache_name
;
794 int var_smtp_sasl_auth_cache_time
;
795 bool var_smtp_sasl_auth_soft_bounce
;
800 int smtp_host_lookup_mask
;
801 STRING_LIST
*smtp_cache_dest
;
803 MAPS
*smtp_ehlo_dis_maps
;
804 MAPS
*smtp_generic_maps
;
805 int smtp_ext_prop_mask
;
806 MAPS
*smtp_pix_bug_maps
;
807 HBC_CHECKS
*smtp_header_checks
; /* limited header checks */
808 HBC_CHECKS
*smtp_body_checks
; /* limited body checks */
813 * OpenSSL client state (opaque handle)
815 TLS_APPL_STATE
*smtp_tls_ctx
;
819 /* deliver_message - deliver message with extreme prejudice */
821 static int deliver_message(const char *service
, DELIVER_REQUEST
*request
)
827 msg_info("deliver_message: from %s", request
->sender
);
830 * Sanity checks. The smtp server is unprivileged and chrooted, so we can
831 * afford to distribute the data censoring code, instead of having it all
834 if (request
->nexthop
[0] == 0)
835 msg_fatal("empty nexthop hostname");
836 if (request
->rcpt_list
.len
<= 0)
837 msg_fatal("recipient count: %d", request
->rcpt_list
.len
);
840 * Initialize. Bundle all information about the delivery request, so that
841 * we can produce understandable diagnostics when something goes wrong
842 * many levels below. The alternative would be to make everything global.
844 state
= smtp_state_alloc();
845 state
->request
= request
;
846 state
->src
= request
->fp
;
847 state
->service
= service
;
848 SMTP_RCPT_INIT(state
);
851 * Establish an SMTP session and deliver this message to all requested
852 * recipients. At the end, notify the postmaster of any protocol errors.
853 * Optionally deliver mail locally when this machine is the best mail
856 result
= smtp_connect(state
);
861 smtp_state_free(state
);
866 /* smtp_service - perform service for client */
868 static void smtp_service(VSTREAM
*client_stream
, char *service
, char **argv
)
870 DELIVER_REQUEST
*request
;
874 * Sanity check. This service takes no command-line arguments.
877 msg_fatal("unexpected command-line argument: %s", argv
[0]);
880 * This routine runs whenever a client connects to the UNIX-domain socket
881 * dedicated to remote SMTP delivery service. What we see below is a
882 * little protocol to (1) tell the queue manager that we are ready, (2)
883 * read a request from the queue manager, and (3) report the completion
884 * status of that request. All connection-management stuff is handled by
885 * the common code in single_server.c.
887 if ((request
= deliver_request_read(client_stream
)) != 0) {
888 status
= deliver_message(service
, request
);
889 deliver_request_done(client_stream
, request
, status
);
893 /* post_init - post-jail initialization */
895 static void post_init(char *unused_name
, char **unused_argv
)
897 static const NAME_MASK lookup_masks
[] = {
898 SMTP_HOST_LOOKUP_DNS
, SMTP_HOST_FLAG_DNS
,
899 SMTP_HOST_LOOKUP_NATIVE
, SMTP_HOST_FLAG_NATIVE
,
904 * Select hostname lookup mechanisms.
907 smtp_host_lookup_mask
= SMTP_HOST_FLAG_NATIVE
;
909 smtp_host_lookup_mask
= name_mask(VAR_SMTP_HOST_LOOKUP
, lookup_masks
,
910 var_smtp_host_lookup
);
912 msg_info("host name lookup methods: %s",
913 str_name_mask(VAR_SMTP_HOST_LOOKUP
, lookup_masks
,
914 smtp_host_lookup_mask
));
917 * Session cache instance.
919 if (*var_smtp_cache_dest
|| var_smtp_cache_demand
)
921 smtp_scache
= scache_multi_create();
923 smtp_scache
= scache_clnt_create(var_scache_service
,
924 var_scache_proto_tmout
,
930 /* pre_init - pre-jail initialization */
932 static void pre_init(char *unused_name
, char **unused_argv
)
937 * Turn on per-peer debugging.
942 * SASL initialization.
944 if (var_smtp_sasl_enable
)
946 smtp_sasl_initialize();
948 msg_warn("%s is true, but SASL support is not compiled in",
949 VAR_SMTP_SASL_ENABLE
);
952 if (*var_smtp_tls_level
!= 0)
953 switch (tls_level_lookup(var_smtp_tls_level
)) {
957 case TLS_LEV_ENCRYPT
:
958 var_smtp_use_tls
= var_smtp_enforce_tls
= 1;
961 var_smtp_use_tls
= 1;
962 var_smtp_enforce_tls
= 0;
965 var_smtp_use_tls
= var_smtp_enforce_tls
= 0;
968 /* tls_level_lookup() logs no warning. */
969 /* session_tls_init() assumes that var_smtp_tls_level is sane. */
970 msg_fatal("Invalid TLS level \"%s\"", var_smtp_tls_level
);
972 use_tls
= (var_smtp_use_tls
|| var_smtp_enforce_tls
);
975 * Initialize the TLS data before entering the chroot jail
977 if (use_tls
|| var_smtp_tls_per_site
[0] || var_smtp_tls_policy
[0]) {
979 TLS_CLIENT_INIT_PROPS props
;
982 * We get stronger type safety and a cleaner interface by combining
983 * the various parameters into a single tls_client_props structure.
985 * Large parameter lists are error-prone, so we emulate a language
986 * feature that C does not have natively: named parameter lists.
989 TLS_CLIENT_INIT(&props
,
990 log_level
= var_smtp_tls_loglevel
,
991 verifydepth
= var_smtp_tls_scert_vd
,
992 cache_type
= strcmp(var_procname
, "smtp") == 0 ?
993 TLS_MGR_SCACHE_SMTP
: TLS_MGR_SCACHE_LMTP
,
994 cert_file
= var_smtp_tls_cert_file
,
995 key_file
= var_smtp_tls_key_file
,
996 dcert_file
= var_smtp_tls_dcert_file
,
997 dkey_file
= var_smtp_tls_dkey_file
,
998 eccert_file
= var_smtp_tls_eccert_file
,
999 eckey_file
= var_smtp_tls_eckey_file
,
1000 CAfile
= var_smtp_tls_CAfile
,
1001 CApath
= var_smtp_tls_CApath
,
1002 fpt_dgst
= var_smtp_tls_fpt_dgst
);
1003 smtp_tls_list_init();
1005 msg_warn("TLS has been selected, but TLS support is not compiled in");
1015 * Session cache domain list.
1017 if (*var_smtp_cache_dest
)
1018 smtp_cache_dest
= string_list_init(MATCH_FLAG_NONE
, var_smtp_cache_dest
);
1021 * EHLO keyword filter.
1023 if (*var_smtp_ehlo_dis_maps
)
1024 smtp_ehlo_dis_maps
= maps_create(VAR_SMTP_EHLO_DIS_MAPS
,
1025 var_smtp_ehlo_dis_maps
,
1029 * PIX bug workarounds.
1031 if (*var_smtp_pix_bug_maps
)
1032 smtp_pix_bug_maps
= maps_create(VAR_SMTP_PIX_BUG_MAPS
,
1033 var_smtp_pix_bug_maps
,
1039 if (*var_prop_extension
)
1040 smtp_ext_prop_mask
=
1041 ext_prop_mask(VAR_PROP_EXTENSION
, var_prop_extension
);
1042 if (*var_smtp_generic_maps
)
1044 maps_create(VAR_SMTP_GENERIC_MAPS
, var_smtp_generic_maps
,
1045 DICT_FLAG_LOCK
| DICT_FLAG_FOLD_FIX
);
1048 * Header/body checks.
1050 smtp_header_checks
= hbc_header_checks_create(
1051 VAR_SMTP_HEAD_CHKS
, var_smtp_head_chks
,
1052 VAR_SMTP_MIME_CHKS
, var_smtp_mime_chks
,
1053 VAR_SMTP_NEST_CHKS
, var_smtp_nest_chks
,
1054 smtp_hbc_callbacks
);
1055 smtp_body_checks
= hbc_body_checks_create(
1056 VAR_SMTP_BODY_CHKS
, var_smtp_body_chks
,
1057 smtp_hbc_callbacks
);
1060 /* pre_accept - see if tables have changed */
1062 static void pre_accept(char *unused_name
, char **unused_argv
)
1066 if ((table
= dict_changed_name()) != 0) {
1067 msg_info("table %s has changed -- restarting", table
);
1072 MAIL_VERSION_STAMP_DECLARE
;
1074 /* main - pass control to the single-threaded skeleton */
1076 int main(int argc
, char **argv
)
1078 #include "smtp_params.c"
1079 #include "lmtp_params.c"
1083 * Fingerprint executables and core dumps.
1085 MAIL_VERSION_STAMP_ALLOCATE
;
1088 * XXX At this point, var_procname etc. are not initialized.
1090 smtp_mode
= (strcmp(sane_basename((VSTRING
*) 0, argv
[0]), "smtp") == 0);
1093 * Initialize with the LMTP or SMTP parameter name space.
1095 single_server_main(argc
, argv
, smtp_service
,
1096 MAIL_SERVER_TIME_TABLE
, smtp_mode
?
1097 smtp_time_table
: lmtp_time_table
,
1098 MAIL_SERVER_INT_TABLE
, smtp_mode
?
1099 smtp_int_table
: lmtp_int_table
,
1100 MAIL_SERVER_STR_TABLE
, smtp_mode
?
1101 smtp_str_table
: lmtp_str_table
,
1102 MAIL_SERVER_BOOL_TABLE
, smtp_mode
?
1103 smtp_bool_table
: lmtp_bool_table
,
1104 MAIL_SERVER_PRE_INIT
, pre_init
,
1105 MAIL_SERVER_POST_INIT
, post_init
,
1106 MAIL_SERVER_PRE_ACCEPT
, pre_accept
,